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.

When TargetFramework=net5.0-windows, dotnet pack uses net5.0-windows7.0 instead

See original GitHub issue

I can’t tell if this is by design or if it’s a bug, and I couldn’t find any documentation via search engines that would explain this. I also read the Target Framework Names in .NET 5 design spec and didn’t see any mention of this behavior there.

When running dotnet build on a .NET 5 WPF app or .NET 5 Windows Forms App with a TargetFramework set to net5.0-windows, all artifacts are correctly written to bin\{Configuration}\net5.0-windows as expected.

However, when running dotnet pack on the same project, the artifacts in the .nupkg are stored in /lib/net5.0-windows7.0 instead of /lib/net5.0-windows which is what one would expect.

image

To reproduce:

mkdir repro
cd repro
dotnet new wpf --framework net5.0
dotnet pack repro.csproj

repro.csproj

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

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5.0-windows</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
  </PropertyGroup>

</Project>

Expectation

The expectation is that dotnet pack would honor exactly what has been defined in the .csproj and exactly what is written to the disk… Which leads me to believe that this could be a bug in dotnet pack.

If this is by design, then I’d like to put in a feature request to throw an error that prevents devs from using net5.0-windows in WPF & WinForms projects and force developers to be specific with net5.0-windows7.0 or net5.0-windows10.0.17763.0 instead, because otherwise it is very confusing to have net5.0-windows in the project, net5.0-windows on disk in the build output, but then a different folder in the NuGet package.


C:\Users\augustoproiete>dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.100
 Commit:    5044b93829

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.100\

Host (useful for support):
  Version: 5.0.0
  Commit:  cf258a14b7

.NET SDKs installed:
  2.1.801 [C:\Program Files\dotnet\sdk]
  2.1.802 [C:\Program Files\dotnet\sdk]
  2.2.401 [C:\Program Files\dotnet\sdk]
  3.1.101 [C:\Program Files\dotnet\sdk]
  3.1.102 [C:\Program Files\dotnet\sdk]
  3.1.302 [C:\Program Files\dotnet\sdk]
  3.1.404 [C:\Program Files\dotnet\sdk]
  5.0.100 [C:\Program Files\dotnet\sdk]

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:9
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
Skyppidcommented, Nov 16, 2020

I had the same phenomenon and when I tried to install these packages in a .NET 5 app, it told me that “net5.0” and “net.5.0-windows7.0” aren’t compatible. All my projects where “net5.0-windows” actually, though.

3reactions
nkolev92commented, Dec 2, 2020

The pack behavior described in spec is carries the gist of platform versions are required in packages, but doesn’t use the terminology that was implemented.

See

TFM has an OS but no OS version. If the user omits the OS version number from the project's <TargetFramework> property, all usages of the TFM should not contain an OS version number, including the project's output directory, the lib folder in the NuGet package, and other corresponding entries in the .nuspec. However, the effective OS version will be recorded in the .nuspec's <platform> element that corresponds to the TFM.

I think this is ok, because the general spec can’t reasonable call out all technical details.

I think it’d be nice to have specific docs describing this behavior.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Target frameworks in SDK-style projects - .NET
NET 5 introduced the net5.0-windows OS-specific TFM, which includes Windows-specific bindings for WinForms, WPF, and UWP APIs.
Read more >
net5.0" and "net.5.0-windows7.0" aren't compatible [closed]
1 Answer 1 ... One of your project has net5.0 as main target, and this project has reference to other project that targets...
Read more >
Publishing a Windows NET 5.0 application wants 'net5.0- ...
I have a NET 5.0 targeted application which builds and runs just fine, under VS2019 and also the trial of Rider 2020.3.2.
Read more >
Experimenting with .NET 5 Target Framework Names and the ...
Currently we're using net5.0-windows and as we saw this maps to version 7 of the Windows platform. If we change the tfm to...
Read more >
Problem with uploading .net6 nuget package to ...
I have developed a Windows Project solution in UiPath that uses a nuget package that has been build and created from a .net6...
Read more >

github_iconTop Related Medium Post

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