Can I specify a target framework based on the os?

Taeo Kim 0 Reputation points
2023-07-20T08:27:32.74+00:00

User's image

User's image

I have a public library used by various applications. There are four target frameworks in the library: netstandard 2.0 netframework 4.7.2 netframework 4.0 netframework 2.0.

After updating to the latest version of vs. mac, the above error occurred.

The exact cause of the problem is unknown, but if you look at it simply, you can compile it separately for each OS.
I wonder if there is such a function.

Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
Community Center | Not monitored
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anna Xiu-MSFT 31,156 Reputation points Microsoft External Staff
    2023-07-21T03:39:14.05+00:00

    Hi @Taeo Kim

    Welcome to Microsoft Q&A! 

    Which version of Visual Studio are you using? 

    For .NET Framework 4.7.2, please go to your Visual Studio Installer > Modify > Individual components > ensure that “.NET Framework 4.7.2 targeting pack” and “.NET Framework 4.7.2 SDK” are checked. 

     

    For .NET Framework 4.0, it has ended for support and its developer pack is not available currently.

    Alternatively, you can add a reference to Microsoft.NETFramework.ReferenceAssemblies.net40 by right-clicking on project > Manage NuGet Packages > Browse > search “Microsoft.NETFramework.ReferenceAssemblies.net40” > install it.

    Then, rebuild your solution. 

    For more details, please refer to: Build apps against reference assemblies.

     

    For .NET Framework 2.0, please type “Turn Windows features on or off“ in the start search box > select “.NET Framework 3.5 (includes .NET 2.0 and 3.0)” check box > OK > wait for installing > restart computer.

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.