Publish Prerelease NuGet Package With Version From .yml File

Dave Glick's Avatar

Dave Glick

17 Mar, 2015 07:15 PM

I'm having trouble publishing a prerelease NuGet package. I've set up several projects this way without problems, but this is the first time I've tried to publish a prerelease package. I have a .yml file with the following:

version: 1.0.0-rc1
...
assembly_info:
  patch: true
  file: AssemblyInfo.*
  assembly_version: "{version}"
  assembly_file_version: "{version}"
  assembly_informational_version: "{version}"

And my .nuspec has:

<version>$version$</version>

The error I'm getting during build is:

nuget pack "C:\projects\linqpad-codeanalysis\LINQPad.CodeAnalysis\LINQPad.CodeAnalysis.csproj" -Properties "Configuration=Release;Platform=AnyCPU" -OutputDirectory "C:\Users\appveyor\AppData\Local\Temp\b20uuqrm72"
Attempting to build package from 'LINQPad.CodeAnalysis.csproj'.
Packing files from 'C:\projects\linqpad-codeanalysis\LINQPad.CodeAnalysis\bin\Release'.
Using 'LINQPad.CodeAnalysis.nuspec' for metadata.
Found packages.config. Using packages listed as dependencies
A stable release of a package should not have on a prerelease dependency. Either modify the version spec of dependency "Microsoft.CodeAnalysis.Compilers (? 1.0.0-rc1)" or update the version field.

I'm guessing that what's going on is that the version is being patched into the assembly info, but is loosing the "-rc1" part in the process. Then the NuGet packing process is supposed to pick up the patched version, but since it's lost the "-rc1" part, NuGet thinks I'm packing up version "1.0.0". Does that sound about right?

So I guess the question is, how do I ensure that the version specified in the .yml file gets passed all the way through to the nuget command?

  1. Support Staff 1 Posted by Feodor Fitsner on 18 Mar, 2015 04:25 AM

    Feodor Fitsner's Avatar

    Hi Dave,

    I've just tested this scenario on a simple project and it worked.
    Repo: https://github.com/FeodorFitsner/nuget-test
    nuspec: https://github.com/FeodorFitsner/nuget-test/blob/master/MyNuGetLib/...
    appveyor.yml: https://github.com/FeodorFitsner/nuget-test/blob/master/appveyor.yml
    build results: https://ci.appveyor.com/project/FeodorFitsner/nuget-test/build/1.0....

    Btw, make sure your AssemblyInfo.cs contains AssemblyInformationalVersion attribute: https://github.com/FeodorFitsner/nuget-test/blob/master/MyNuGetLib/...
    Only AssemblyInformationalVersion can hold non-numeric version and this is the value that will be used in <version>$version$</version>.

  2. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 01:55 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac