Closed cmenzi closed 4 years ago
This is by design.
NuGet explicitly excludes those targets from affecting restore. If a package contains a build/package.targets file that contains a PackageReference the output of restore will change based on if the project had previously been restored.
See https://github.com/NuGet/Home/issues/3604.
Doc issue to clarify this: https://github.com/NuGet/docs.microsoft.com-nuget/issues/1872
The Visual Studio experience is different due to a project-system bug, see: https://github.com/dotnet/project-system/issues/3734
If your package has dependencies, it should declare them as such. Otherwise you might need to consider an msbuild sdk, like https://github.com/microsoft/MSBuildSdks
I have a
tools.props
file which contains somePackageReference
's. When I import the file into a.csproj
either via<Import Project="tools.props" />
or via a NuGet package where to 'tools.propsfile in packed into the
buildfolder, then all dependencies defined in the
.propsare not appearing in
project.assets.json`.The funny thing is, that when using VS 2019 and build it, then everything works and
project.assets.json
created correctly.But when using
dotnet restore
command ormsbuild /t:restore
the dependency are not itproject.assets.json
.tools.props
When I define the
ItemGroup
directly in the.csproj
and not in the.props
file, then it works aswell.Why is the behavoir differnent in VS than in msbuild or dotnet restore?
Is there a hint, flag, property to pass, they dotnet restore should handle those package references same as they would be directly defined in the csproj?