pardahlman
pardahlman

Reputation: 1454

Version Suffix not honored when creating NuGet packages with project references

I recently migrated my .NET Core projects from project.json to .csproj. The solution contains multiple projects, some of which references project using ProjectReference.

    <ItemGroup>
        <ProjectReference Include="..\RawRabbit\RawRabbit.csproj" />
    </ItemGroup>

I have a PowerShell script that I've for a long time, that traverses the project folders and creates NuGet packages for each project

dotnet pack -c Release -o ..\..\artifacts --version-suffix=$buildSuffix

Where $buildSuffix is something like beta7. The version suffix is shared between all project dependencies, meaning that all project dependencies are for a pre-release uses the same version suffixed (beta7 in this example).

In order for the package to get the right version suffix, I've updated the csproj so that my projects are using VersionPrefix rather than Version

    <PropertyGroup>
        <VersionPrefix>2.0.0</VersionPrefix>
    </PropertyGroup>

The NuGet package gets the right version number (e.g. 2.0.0-beta7), but the project dependencies in the nuspec file (within the nupkg file) are referenced without the VersionSuffix used during build.

<dependencies>
  <group targetFramework=".NETStandard1.5">
    <dependency id="RawRabbit" version="2.0.0" exclude="Build,Analyzers" />
  </group>
</dependencies>

This is problematic, as my newly created pre-release gets a dependency an release that does not exist (in this case 2.0.0 rather than 2.0.0-beta7).

I'm not really sure if this is the expected behavior, if so: any ideas as how I would configure my build so that it honors the VersionSuffix when creating NuGet package?

Upvotes: 2

Views: 1593

Answers (1)

pardahlman
pardahlman

Reputation: 1454

Ok, so looks like it is a bug after all:

https://github.com/NuGet/Home/issues/4337 https://github.com/dotnet/cli/issues/6025

Upvotes: 1

Related Questions