Home: Nuget 5.8.0.6930 cannot handle projects that support multiple .net framework versions

Created on 17 Nov 2020  路  11Comments  路  Source: NuGet/Home

Details about Problem

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe):

NuGet version (x.x.x.xxx): Nuget 5.8.0.6930

Worked before? If so, with which NuGet version: 5.7

Detailed repro steps so we can see the same problem

  1. Create a .net .vcsproj project that supports multiple .net framework versions

  2. Try to have the project build on Azure Devops with the latest version of Nuget

The build will fail with the error:
`

[error]The nuget command failed with exit code(1) and error(Invalid restore input. Duplicate frameworks found: 'net472, net472'. Input files: D:\a\1\s\Product\Source\BIMrxCommon\Microdesk.BIMrxCommon.DbApp\Microdesk.BIMrxCommon.DbApp.csproj.

`
...

Other suggested things

On this past Monday 09/11/2020 all our builds on Azure Devops started failing.
The error message we did get was

[error]The nuget command failed with exit code(1) and error(Invalid restore input. Duplicate frameworks found: 'net472, net472'. Input files: D:\a\1\s\Product\Source\BIMrxCommon\Microdesk.BIMrxCommon.DbApp\Microdesk.BIMrxCommon.DbApp.csproj.

The version of nuget used by Azure was: NuGet version 5.8.0.6930
* After forcing the build script to use Nuget 5.7 the problems did disappear. *
It looks that the latest nuget version has problems with projects that support multiple .net framework versions

At first I did create a report against Azure pipelines, but was told to report it here.
https://github.com/microsoft/azure-pipelines-tasks/issues/13887

Verbose Logs

Please include verbose logs (NuGet.exe -verbosity detailed | dotnet.exe --verbosity diag | etc...)

Sample Project

To reproduce, probably it is enough to add the following code to your project:
<PropertyGroup> <TargetFrameworks>net472;net48</TargetFrameworks> </PropertyGroup>

NugetLog5.8.zip

Restore 1 NeedsRepro Bug WaitingForCustomer

Most helpful comment

We owe the community some more guidance on this, but I'd recommend using msbuild /t:restore wherever possible.
It guarantees you are using the restore tooling perfectly matched to the build tooling. For example, that's how we build our own repo.
At this point, msbuild /t:restore has equivalent capabilities to nuget.exe restore.

All 11 comments

Hey @sylvesp

Can you post the contents of your project file/repro project?
I'm not familiar with vcsproj.

Using a regular SDK based csproj, I am not able to repro this when using nuget.exe 5.8.0

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>net472;net48</TargetFrameworks>
    <RootNamespace>_10289</RootNamespace>
  </PropertyGroup>

</Project>

I have the same problem:
The nuget command failed with exit code(1) and error(Invalid restore input. Duplicate frameworks found: 'net462, net5.0, net5.0, netstandard2.0, uap10.0.16299'.

With attached project (when referenced by another .NET 5.0 one).
HaSaM.Configurations.csproj.zip

@rolfik

That's likely because of the MSBuild.SDk.Extras usage.

NuGet reads TargetFrameworkMoniker and TargetPlatformMoniker and it's likely that extras might not be setting them.

However, I can't repro your problem. What's the version of the Sdk that you are using?
The csproj example doesn't have the version and it's likely declared in a global.json.

@nkolev92
I use current version of MSBuildSdkExtras built locally and packed into nuget.

I see. There's 2 ways we can confirm what you are seeing.

  1. Please run msbuild or dotnet restore and provide us a bin log. Keep in mind that the binlog collects all env vars, so it can leak secrets.
  2. Generate a binlog and investigate yourself, like here: paint
    Find all 5 TargetFrameworkInformation for that project and post the TargetFrameworkMoniker, TargetPlatformMoniker values.

Actually I can build the project with Visual Studio 16.8.1 well, but when building it in Azure Pipeline nuget.exe restore command just failed with the error mentioned. The pipeline runs on the same computer as the working Visual Studio.

I cannot find how to specify /bl binary log swith with nuget.exe (5.8).

But after more investigations, I have found there was a mismatch in .global.json files specifying newest MSBuildSdkExtras in nested git submodules. After clearing it and ensuring all specify the latest version, the pipeline build now works for me.

Glad you were able to resolve your problem.

For future reference, nuget.exe binlogs are a little bit trickier than dotnet.exe, msbuild.exe restore.
You'd need to set an env var, https://docs.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-environment-variables, NUGET_RESTORE_MSBUILD_ARGS.

Out of curiosity, any particular reason you are using nuget.exe for restore?

Out of curiosity, any particular reason you are using nuget.exe for restore?

Nothing special. It comes from default Azure pipeline for build with Visual Studio.

We owe the community some more guidance on this, but I'd recommend using msbuild /t:restore wherever possible.
It guarantees you are using the restore tooling perfectly matched to the build tooling. For example, that's how we build our own repo.
At this point, msbuild /t:restore has equivalent capabilities to nuget.exe restore.

@nkolev92 is this something we can wrap up, or should we create new issues for other stuff?

No response from the OP yet, so I'm gonna close this for now.

Happy to re-open if/when we get more details.

Was this page helpful?
0 / 5 - 0 ratings