OctoPackNuGetProperties usage for multiple properties

The documentation for Replacement tokens at http://docs.octopusdeploy.com/display/OD/Using+OctoPack suggests that I can pass multiple properties through MSBuild to a .nuspec by using OctoPackNuGetProperties. I successfully can pass one property, but when I try to pass two properties (in either order) the second property is not getting passed, resulting in an error.

As you’ll see on the last line of the output below, the second property never gets sent to the NuGet.exe Pack command. Any idea what I’m doing wrong? I’ve tried breaking down the Nant [exec] command to a straight MSBuild call on the command line and I still get the same error. Thanks.

Partial .nuspec:

  <metadata>
    <id>$ProjectName$</id>
    <version>$version$</version>
    <authors>redacted</authors>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>The $ProjectName$ deployment package, built on $BuildDate$</description>
  </metadata>

Nant script command line:

	<exec program="${MSBuildPath}" verbose="true">
		<arg line='"${SolutionFile}"' />
		<arg line="/property:Configuration=${BuildConfig}" />
		<arg line="/property:RunOctoPack=true" />
		<arg line="/property:OctoPackNuGetProperties=BuildDate=${build.date};ProjectName=${StartupProjectName}" />
		<arg value="/target:${BuildTarget}" />
		<arg value="/verbosity:minimal" />
		<arg value="/nologo" />
	</exec>

Output, including error message:

     [exec]   OctoPack: Attempting to build package from 'redacted.Web.nuspec'.
     [exec] MSBUILD : OctoPack error OCTONUGET: The replacement token 'ProjectName' has no value. [C:\Projects\redacted\Octopus\redacted.Web\redacted.Web.csproj]
     [exec] MSBUILD : OctoPack error OCT-1676060969: There was an error calling NuGet. Please see the output above for more details. Command line: 'C:\Projects\redacted\Octopus\packages\OctoPack.3.0.53\tools\NuGet.exe' pack "C:\Projects\redacted\Octopus\redacted.Web\obj\octopacking\redacted.Web.nuspec"  -NoPackageAnalysis -BasePath
"C:\Projects\redacted\Octopus\redacted.Web" -OutputDirectory "C:\Projects\redacted\Octopus\redacted.Web\obj\octopacked" -Version 0.8.5955.13425 -Properties BuildDate=04/21/2016 [C:\Projects\redacted\Octopus\redacted.Web\redacted.Web.csproj]

Hi Russel,

Thanks for getting in touch.

In order to include multiple OctoPackNuGetProperties in your Nant build configuration you will need to enclose the properties in quotes. For example:

<arg line='/property:OctoPackNuGetProperties="BuildDate=${build.date};ProjectName=${StartupProjectName}"' />

You could also try calling NuGet.exe directly (as this is what OctoPack does under the hood):

nuget.exe pack MyProject.nuspec -Properties "BuildDate=BuildDate=04/21/2016;ProjectName=MyProject"

I have a feeling you will continue to see “The replacement token ‘ProjectName’ has no value.” but this might help debug why it is happening.

Please let me know if you get stuck.

Cheers,
Shane

I didn’t have any other Nant properties in my .build file delimited in single-quotes like that, but that arg line worked like a charm, exactly as you sent it. Thank you!