question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nbgv install adds PackageReference even to vcxproj projects, which breaks their build

See original GitHub issue

Hello,

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:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
tmilnthorpcommented, Nov 16, 2020

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.

1reaction
tmilnthorpcommented, Nov 14, 2020

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

<CLRSupport>true</CLRSupport>

I believe this value can also be netcore for some C++/Cli projects.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found