I have a .NET Framework 4.8 C# class library project that I want to target to .NET Standard 2.0 for interop with a new .NET 6 project. In the project settings in Visual Studio (tried in both 2019 and 2022, same results), there's no option to target .NET Standard.
If I select "Install other frameworks", it takes me out to the .NET download page. The .NET Standard section on this page says
.NET Standard is a formal specification of .NET APIs that are intended to be available on all .NET implementations. To target .NET Standard in your projects, install one of the SDKs from the .NET/.NET Core table.
Here's a screenshot of that table. Confusingly, no SDKs for VS 2022 or .NET 6 are even listed.
I decide to run dotnet --list-sdks
to see what I already have installed, and I get this.
3.1.416 [C:\Program Files\dotnet\sdk]
5.0.203 [C:\Program Files\dotnet\sdk]
5.0.210 [C:\Program Files\dotnet\sdk]
5.0.303 [C:\Program Files\dotnet\sdk]
5.0.403 [C:\Program Files\dotnet\sdk]
5.0.404 [C:\Program Files\dotnet\sdk]
6.0.101 [C:\Program Files\dotnet\sdk]
So it seems that I have everything in place to be able to target .NET Standard 2.0 from this project, but I see no way in Visual Studio to do that. I'm dismayed by how unintuitive this process is. How do I proceed?
You could always try setting it by hand in your.csproj by replacing the value of the TargetFramework
property with netstandard2.0
:
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.