In Visual Studio I create a sample WPF project targeting .NET6, then I create a library targeting .NET Standard 2.0 which I reference from the .NET6 project.
Then when I run dotnet publish WpfAfpp1.sln --framework net6.0-windows
,
I get this error:
error NETSDK1005: Assets file 'C:\Users\STEMAL\source\repos\WpfApp1\ClassLibrary1\obj\project.assets.json' doesn't have a target for 'net6.0-windows'. Ensure that restore has run and that you have included 'net6.0-windows' in the TargetFrameworks for your project. [C:\Users\STEMAL\source\repos\WpfApp1\ClassLibrary1\ClassLibrary1.csproj]
Why does this happen? Isn't netstandard2.0 supposed to be supported by .NET 6?
The library should preferably just have the netstandard2.0 target, and the reason I am using the --framework configuration on dotnet publish is because I have some multi targeted projects in my solution.
You can only publish a project (and not a solution). Try :
dotnet publish WpfAfpp1.csproj --framework net6.0-windows