Unable to deploy empty folders

Hi Team,
I’m using octopus tools for deployment in my project process.using jenkins to create octopack.

Problem: I need Empty folders for my project deployment.

Example:We have A,B,C,D folders and A,B,C have code and D have no code(empty folder).But my project deployment process I need “D” folder as well.Is there any option deploy all the folders include .txt files like that…
I need couple of empty folder to deploy.Based on that empty folder code will be dependent.
Make sense in the problem?

Here is my windows batch commands using jenkins:
@ECHO OFF
REM Jenkins server settings
SET EXE_PATH=d:\OctopusTools

REM Octopus Deploy settings
SET OCTO_SERVER="***“
SET OCTO_API_KEY=”***"

REM Version numbering system based on Semantic Versioning (SemVer) scheme
REM http://semver.org/
SET VERSION_MAJOR=1
SET VERSION_MINOR=0
SET VERSION_PATCH=%BUILD_NUMBER%
SET VERSION_NUMBER=%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH%

REM Package settings
REM Note: Substitute ‘.’ with '’ to ensure a legal NuGet package id
SET PACKAGE_ID=%JOB_NAME:.=
%
SET PACKAGE_NAME=%PACKAGE_ID: =%.%VERSION_NUMBER%.nupkg

REM Show variable values
ECHO ----------------------------------
ECHO Packaging %PACKAGE_NAME%
ECHO Version %VERSION_NUMBER%
ECHO Workspace %WORKSPACE%
ECHO Octopus Deploy Server %OCTO_SERVER%
ECHO ----------------------------------

REM Package %WORKSPACE% directory
DEL /F /Q *.nupkg
%EXE_PATH%\Octo.exe pack --id=%PACKAGE_ID% --overwrite --version=%VERSION_NUMBER% --basePath="%WORKSPACE%" --outFolder=%NuGet_SOURCE%
IF ERRORLEVEL 0 GOTO PublishNuGet
ECHO FAILED to PACKAGE %PACKAGE_NAME% using Octo.exe
ECHO Octo.exe return code = %ERRORLEVEL%
EXIT

REM Publish NuGet package to Octopus Deploy Server
:PublishNuGet
%EXE_PATH%\NuGet.exe push “%NuGet_SOURCE%%PACKAGE_NAME%” -ApiKey %OCTO_API_KEY% -Source “%OCTO_SERVER%” -Verbosity detailed
IF ERRORLEVEL 0 GOTO Finalize
ECHO FAILED to PUBLISH %PACKAGE_NAME% using NuGet.exe
ECHO Octo.exe return code = %ERRORLEVEL%
EXIT

Team,
Could you please help on this,
satish

Hi Satish,

Thanks for reaching out. Octo.exe wont include empty folders on your package. What you can do is use Nuget.exe pack instead, and add a nuspec file with the <file> tag to add an empty directory to your package.

Nuget.exe pack reference: https://docs.nuget.org/release-notes/nuget-2.2#specify-entire-folder-for-package-contents

nuspec reference for empty directories: https://docs.nuget.org/release-notes/nuget-2.2#specify-entire-folder-for-package-contents

Hope that helps!

Dalmiro

Hi Dalmiro,

Thanks for the update and i just try it ,But no luck.

Could you please tell me where i need to change like i need to change in my batch script from Octo.exe to Nuget.exe.

Previous:
REM Package %WORKSPACE% directory
DEL /F /Q *.nupkg
%EXE_PATH%\Octo.exe pack --id=%PACKAGE_ID% --overwrite --version=%VERSION_NUMBER% --basePath="%WORKSPACE%" --outFolder=%NuGet_SOURCE%
IF ERRORLEVEL 0 GOTO PublishNuGet
ECHO FAILED to PACKAGE %PACKAGE_NAME% using Octo.exe
ECHO Octo.exe return code = %ERRORLEVEL%
EXIT

REM Publish NuGet package to Octopus Deploy Server
:PublishNuGet
%EXE_PATH%\NuGet.exe push “%NuGet_SOURCE%%PACKAGE_NAME%” -ApiKey %OCTO_API_KEY% -Source “%OCTO_SERVER%” -Verbosity detailed
IF ERRORLEVEL 0 GOTO Finalize
ECHO FAILED to PUBLISH %PACKAGE_NAME% using NuGet.exe
ECHO Octo.exe return code = %ERRORLEVEL%
EXIT

Modified:
REM Package %WORKSPACE% directory
DEL /F /Q *.nupkg
%EXE_PATH%\Nuget.exe pack --id=%PACKAGE_ID% --overwrite --version=%VERSION_NUMBER% --basePath="%WORKSPACE%" --outFolder=%NuGet_SOURCE%
IF ERRORLEVEL 0 GOTO PublishNuGet
ECHO FAILED to PACKAGE %PACKAGE_NAME% using Nuget.exe
ECHO Nuget.exe return code = %ERRORLEVEL%
EXIT

REM Publish NuGet package to Octopus Deploy Server
:PublishNuGet
%EXE_PATH%\Nuget.exe push “%NuGet_SOURCE%%PACKAGE_NAME%” -ApiKey %OCTO_API_KEY% -Source “%OCTO_SERVER%” -Verbosity detailed
IF ERRORLEVEL 0 GOTO Finalize
ECHO FAILED to PUBLISH %PACKAGE_NAME% using Nuget.exe
ECHO Nuget.exe return code = %ERRORLEVEL%
EXIT

It won’t work and where can we do this…add a nuspec file with the tag to add an empty directory to your package.

please modify my script accordingly.

Finally we have any option on octopus tool configuration to set the empty folders deployment option.like to set the variables
Could you please tell me the step by step.it will very helpful to me.

Thanks
satish

Hi Satish,

On your modified script I see that you are using Nuget.exe with the same parameters as Octo.exe.

%EXE_PATH%\Nuget.exe pack --id=%PACKAGE_ID% --overwrite --version=%VERSION_NUMBER% --basePath="%WORKSPACE%" --outFolder=%NuGet_SOURCE%

Nuget.exe is a completely different tool which has its own parameters. I can see that you are using the tool correctly when pushing the package later on in your script

%EXE_PATH%\Nuget.exe push "%NuGet_SOURCE%\%PACKAGE_NAME%" -ApiKey %OCTO_API_KEY% -Source "%OCTO_SERVER%" -Verbosity detailed 

The correct sintax for Nuget.exe pack goes a bit like this:

Nuget.exe pack [path of your nuspec file]

The nuspec file is an xml manifest that Nuget uses to set the metadata of your package. You can read more about it here: http://docs.nuget.org/Create/Nuspec-Reference

You can use this basic nuspec file as a starting point to build your own. Please keep in mind that this one wont work out of the box, so you’re gonna have to read the NuGet/Nuspec documentation.

<?xml version="1.0"?>
<package >
  <metadata>
    <id>MyPackage</id>
    <version>1.0.0</version>
    <authors>Paul</authors>
    <owners>Paul</owners>
    <licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl>
    <projectUrl>http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE</projectUrl>
    <iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Package description</description>
    <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
    <copyright>Copyright 2015</copyright>
    <tags>Tag1 Tag2</tags>
    <dependencies>
      <dependency id="SampleDependency" version="1.0" />
    </dependencies>
  </metadata>
</package>

Once you get the hang of using nuspec files, you can add the <file> tags to tell Nuget to force adding an empty folder to a directory within your package.

Best regards,

Dalmiro