Using version value from nuspec to set version of nuget package


We just upgraded to Octopck 2.0 and now I have a question.

Before we where able to use the version-number in the nuspec file to set the version of the nuget package by adding -Version “$(OctopusPackageVersion)” to the Nuget Command.

This does not work anymore. Is there a way to solve this?


Hi Nils,

OctoPack passes -version to NuGet.exe using an MSBuild property called $(OctoPackPackageVersion) (note the prefix is now OctoPack rather than Octopus).

If you set OctoPackPackageVersion yourself, we use that value. For example:


If you don’t set it, we try to infer it from the .NET assembly version. Failing that, we use the value in the NuSpec.

Hope that helps,


Hi Paul,

I’m trying to get this working respecting the valus in the NuSpec. How can i force this to avoid getting the value from /p:OctoPackPackageVersion and the .Net Assembly version?

Hi Dalmiro,

Thanks for the reply. At the moment the only workaround is to modify the OctoPack.targets file and remove lines 45-47:

As you can see in the file above, those lines set the version to be the assembly version (note that Octopus uses AssemblyInformationalVersion before AssemblyVersion, if that helps you) if the value is empty. Removing them will allow it to fall back to the NuSpec version.


The line numbers that Paul mentioned might vary with future commits. To avoid any confusion, these are the lines that have to be commented on Octopack.targets:

	<OctoPackPackageVersion Condition="'$(OctoPackPackageVersion)' == ''">%(AssemblyVersions.Version)</OctoPackPackageVersion>

I tried using the [assembly:AssemblyInformationalVersion(“x.x.x”)] of the Project AssemblyInfo file, this info is then used as the Version of the Package created using the Octopack (MSBuildArugments). This approach does not require to modify the Octopak target files.

If anyone facing similar issue, please note the version detail in the .Nuspec file does not work, only the AssemblyInfo file content OR the MSBuildParameter - /p:OctoPackPackageVersion - can override it.

Hi Selvakumar,

To add to this, we have this documented on our OctoPack documentation page under Version Numbers. We have always taken these settings over priority of a NuSpec.

NuGet packages have version numbers. When you use OctoPack, the NuGet package version number will come from (in order of priority):

  • The command line, if you pass /p:OctoPackPackageVersion= as an MSBuild parameter when building your project.
  • If the [assembly: FileVersion] is the same as the [assembly: AssemblyInformationalVersion] (AKA ProductVersion), then we’ll use the [assembly: AssemblyVersion] attribute in your AssemblyInfo.cs file
  • Otherwise we take the [assembly: AssemblyInformationalVersion].


Adding to this, is there a chance to add the AssemblyVersion as the package version and attach the build number from a Jenkins build (Jenkins uses ${BUILD_NUMBER} variable in OctoPackPackageVersion parameter).
I’d like to have something like: 2016.07.20.99 = YYYY.MM.DD.BUILD

Is it possible? If yes how? I’m desperate. Having just the AssemblyVersion is not enough anymore for tracking purposes.

Hi Alex,

Thanks for reaching out! As it was previously mentioned in this thread, you can use the MSBuild parameter /p:OctoPackPackageVersion to tell Octopack to pass a specific value as package version. With that in mind, all you need is to figure out how to build the “YYYY.MM.DD.BUILD” using variables from Jenkins at build time (unfortunately we do not have this info).


Hi, thanks for the info. I had that in mind, but haven’t come up with a
solution thus far. Octopack overwrites the Assembly version and that is not
what i have in mind because i will have no tracking in GitLab.
Thanks for the support!

Hi Alex - Sorry to hear that didn’t help you at all :(. I guess you’re gonna have to have a step dedicated to pack your application, and you’re gonna have to figure out how to create your version string to use is as a paremeter in your pack step.

This sounds like a Jenkins question rather than an Octopus one, so you might gonna have more luck in their forum?

Best regards,

Yes, i agree. Thanks for the tip. I will follow it further

Thanks allot