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.

Restore failing for projects with tfms netcoreapp3.0;netcoreapp3.0-Windows

See original GitHub issue
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>netcoreapp3.1;netcoreapp3.1-Windows</TargetFrameworks>
  </PropertyGroup>
</Project>

fails during restore while

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>net5.0;net5.0-Windows</TargetFrameworks>
  </PropertyGroup>
</Project>

builds fine

The error in the first case

Build FAILED.

C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\NuGet.targets(130,5): error : Invalid restore input. Duplicate frameworks found: 'netcoreapp3.1, netcoreapp3.1'. Input files: C:\git\scratch\rc2\rc2.csproj. [C:\git\scratch\rc2\rc2.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.68

is this by design ?

cc @ericstj

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
nkolev92commented, Sep 15, 2020

Even though netcoreapp3.1-Windows is a valid target framework, I believe NuGet handles this case differently (as it assumes the suffix is the TargetFrameworkProfile part) and restores differently.

That was the whole TargetFramework as alias problem. NuGet and the SDK both were parsing the TargetFramework element but it wasn’t supposed to be. To enable .NET 5 TFMs, NuGet & SDK switched to combining TargetFrameworkMoniker & TargetPlatformMoniker to infer the true pivot framework.

Now to preserve the consistent behavior for customers (ie simple project files), the TargetFramework property is parsed if TargetPlatformMoniker and TargetFrameworkMoniker are not set. That’s being done in the SDK. As far as NuGet & SDK go, there’s no such thing as a platform specific .NETCoreApp 3.x, so the SDK ends up generating the same TargetFrameworkMoniker + TargetPlatformMoniker.

Hope this clarifies the current behavior.

0reactions
wli3commented, Sep 17, 2020

Let me know if we need to have a better error message (if it is possible at all). Then reopen the issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dotnet restore fails when providing runtime identifier due to ...
It works when I use netcoreapp2.1 as a target framework, but it breaks with netcoreapp3.1 or net5.0 . It also works when I...
Read more >
Select which .NET version to use
Learn how .NET automatically finds and chooses runtime versions for your program. Additionally, this article teaches you how to force a ...
Read more >
Please stop lying about .NET Standard 2.0 support!
In this post I have a bit of a rant about Microsoft's NuGet packages lying about supporting .NET Standard 2.0 when they kinda...
Read more >
Bring Your .NET Apps Forward with the .NET Upgrade ...
After applying this step, you can see that the <TargetFramework> property of the project file has been updated to net6.0 (representing .NET 6.0...
Read more >
Publishing a dotnetcore3.1 app results in an error ...
I am trying to publish my web app (targetframework is netcoreapp3.1) with server side blazor (3.2.0-preview1.20073.1) and am getting “Assets file ...
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