-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When TargetFramework=net5.0-windows, dotnet pack uses net5.0-windows7.0 instead #14553
Comments
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. |
I had the same issue as @Skyppid , in my case it was because I had a project with .net5.0 referencing .net5.0-windows projects. I got it resolved by just changing the .net5.0 to .net5.0-windows as well. |
Confirmed by @zkat on Twitter that this is by design. |
I'll leave this issue open as a suggestion to add some consistency here between the build output, and the NuGet packaged library, either on the .NET SDK side or on the NuGet side. When developing libraries that should be consumed by Windows Desktop apps, and given that I defined However, if set the One alternative could be modifying the logic of the warning
Another alternative could be changing NuGet to use |
I looked through https://github.com/dotnet/designs/blob/main/accepted/2020/net5/net5.md but didn't find anywhere where this was actually documented. I don't think we have it documented anywhere but in our heads right now. Did you have anything, @terrajobst ? |
The See
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. |
I get the same error, specifically:
Both projects use the TFM "net50-windows". If I then go in under .nuget/packages and /lib on the build server and copy the folder "net50-windows7.0" to a new folder "net50-windows", the Nuget error goes away. But then I get this compile error: errorCS0103: The name 'Windows' does not exist in the current context |
What's your SDK version? |
I am not sure. Does the MSBuild log show the SDK version? |
Please take a look at this issue I raised on Stackoverflow and let me know if it is related. Suggestions on how I might fix it will be greatly appreciated. |
It's .NET 8 and the issue persists. I have: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- NOTE THIS! -->
<TargetFramework>net8.0-windows</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Platforms>x64</Platforms>
<!-- further info not relevant -->
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<DebugSymbols>false</DebugSymbols>
<Optimize>true</Optimize>
</PropertyGroup>
<ItemGroup>
<None Update="LibLouis\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>true</Pack>
<Visible>false</Visible>
<!-- NOTE THIS! -->
<PackagePath>lib/$(TargetFramework)</PackagePath>
</None>
<None Include="../../README.md" Pack="true" Visible="false" PackagePath="/" />
</ItemGroup>
</Project> So, In the |
That's expected. net8.0-windows is just sugar around specifying the exact platform version. I think this issue is really on a documentation issue at this point: #14553 (comment). @dsplaisted should we move this to dotnet/docs? |
Yes, this is the way it is supposed to work and it would be good to have that documented, if it isn't already. As for this: <None Update="LibLouis\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>true</Pack>
<Visible>false</Visible>
<!-- NOTE THIS! -->
<PackagePath>lib/$(TargetFramework)</PackagePath>
</None> The |
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 aTargetFramework
set tonet5.0-windows
, all artifacts are correctly written tobin\{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.To reproduce:
repro.csproj
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 indotnet 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 withnet5.0-windows7.0
ornet5.0-windows10.0.17763.0
instead, because otherwise it is very confusing to havenet5.0-windows
in the project,net5.0-windows
on disk in the build output, but then a different folder in the NuGet package.The text was updated successfully, but these errors were encountered: