nbgv install adds PackageReference even to vcxproj projects, which breaks their build
See original GitHub issueHello,
I have a solution that contains some C++/Cli projects, and doing a ngbv install
breaks nuget restore
when run from the command line.
##[error]The nuget command failed with exit code(1) and error(NU1201: Project MyCliProject is not compatible with net462 (.NETFramework,Version=v4.6.2). Project MyCliProject supports: native (native,Version=v0.0)
The issue is that Directory.Build.props adds a ProjectReference for all project types. This fails as the project type is technically “native” for C++/Cli.
I found I can fix this issue my adding a condition to the PackageReference ItemGroup:
<ItemGroup Condition="'$(PlatformToolset)' == ''">
<PackageReference Include="Nerdbank.GitVersioning">
<Version>3.3.37</Version>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
This works since C# projects do not define a PlatformToolset as the C++/Cli projects do.
I would create a PR, but I am unsure if this is a generic enough fix for all supported project types. Your thoughts?
Tristan
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
nbgv does not update the version in Directory.Build.props
However, running nbgv install does not appear to update the PackageReference. It stays at the old version. If I first delete Directory.
Read more >PackageReference in project files - NuGet
Package references, using <PackageReference> MSBuild items, specify NuGet package dependencies directly within project files, as opposed to ...
Read more >.net - Changing a project reference to a NuGet package ...
There are two parts to my answer. Firstly, if you're using dotnet pack or msbuild -t:pack , without a nuspec file, then project...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I tried the
Condition="!Exists('packages.config')"
version in a few large solutions which have a mix of C++, C++/Cli, and C# and it worked well.Sure, you can access a bare-bones repo here.
If you clone, simply do a
nuget retore CppCliFailureNBGC.sln
It will appear to succeed, however you’ll note boost (which is installed in packages.config) isn’t downloaded. Note that packages.config is the only option supported by C++/Cli projects since they are “native” targets.
Perhaps we can key off
I believe this value can also be netcore for some C++/Cli projects.