Reputation: 2452
I've got two .NetStandard NuGet Packages that I'm building in the same solution (A and B)
A has a project reference to B.
By default, when I build in VS it will create me a NuGet package for both projects.
The package A.1.0.0.nupkg
will contain this dependency, which was automatically added by msbuild:
<dependency id="B" version="1.0.0" exclude="Build,Analyzers" />
That works fine, and its automatic which is great.
If I change the Package Version of B, to 2.0.0
and build, the line in A.nuspec
will be automatically updated to:
<dependency id="B" version="2.0.0" exclude="Build,Analyzers" />
This is fantastic, and it works like magic.
Problem is, this does not work if I build using the PackageVersion property:
msbuild /p:PackageVersion="3.0.0"
I would expect that msbuild would create two nupkgs:
A.3.0.0.nupkg
B.3.0.0.nupkg
And it does. However, A.nuspec
still has this dependency:
<dependency id="B" version="2.0.0" exclude="Build,Analyzers" />
I would expect it to be version="3.0.0"
Are there any workarounds for this? Is there a different way I should be configuring my packages?
Upvotes: 0
Views: 777
Reputation: 100791
At the moment (NuGet 4.5.0), the version is locked during the restore operation and not during the package build.
This will be changed in NuGet 4.6.0 (included in VS 15.6).
To work around this, use msbuild /restore /p:PackageVersion=3.0.0
instead.
See this GitHub issue for more details.
Upvotes: 1