MSBuild targets are not applied to generated project.assets.json for project references when packaging from Visual Studio 2017 #6037
Labels
Functionality:Pack
Resolution:Duplicate
This issue appears to be a Duplicate of another issue
Triage:Investigate
Milestone
Details about Problem
NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe):
VS UI
NuGet version (x.x.x.xxx):
4.3.0.4406
4.4.0
dotnet.exe --version (if appropriate):
2.0.0
2.0.2
VS version (if appropriate):
Visual Studio 2017 15.3.5
Visual Studio 2017 15.4.0
OS version (i.e. win10 v1607 (14393.321)):
win10 (10.0.15063 Build 15063)
Worked before? If so, with which NuGet version:
N/A
Detailed repro steps so we can see the same problem
Open the sample project TestSetVersion.zip
Pack the project named
ProjectC
from VS, by right-clicking on the project in the Solution Explorer and selecting PackOnce packed, open the file
TestSetVersion\ProjectC\bin\Debug\ProjectC.1.2.3-r12345.nupkg
(i.e. using NuGet Package Explorer)Verify that the package contains two dependencies with the following versions;
ProjectA >= 1.2.3.r12345
andProjectB >= 1.2.3.r12345
Remove the
\bin
and\obj
output folders fromTestSetVersion\ProjectC\
Open the file
TestSetVersion\Directory.Build.props
, and comment out the target namedBeforeGenerateNuspec
Pack the project named
ProjectC
from VSOnce packed, open the file
TestSetVersion\ProjectC\bin\Debug\ProjectC.1.2.3-r12345.nupkg
(i.e. using NuGet Package Explorer)Verify that the package contains two dependencies with the following (incorrect) versions;
ProjectA >= 1.0.0
andProjectB >= 1.0.0
Based on the above it seems that when a project (
ProjectC
) is referencing other projects (ProjectA
andProjectB
), in the same solution, the versions of the referenced projects will not be set to the version provided by the givenSetVersion
target. This behaviour only seem to occur when packaging the project from inside VS, as calling either MSBuild (msbuild \t:restore \t:pack
) or the .NET Core CLI (dotnet pack
) directly will produce a package forProjectC
that contains dependencies toProjectA
andProjectB
with the version set via theSetVersion
target.It is expected that the file
project.assets.json
is generated with the correct version for the project it belongs to, and also with correct versions forPackageReferences
.Do note that the target
BeforeGenerateNuspec
and the inline taskFixProjectAssetsJson
is indeed a workaround, since it is not fully clear how to use MSBuild targets, since the Restore Target from NuGet doesn’t seem to be executed from VS, and there seems to be no clear public targets available for before or after generating theproject.assets.json
file.The text was updated successfully, but these errors were encountered: