C# 如何仅构建与计算机上安装的内容兼容的项目?

C# 如何仅构建与计算机上安装的内容兼容的项目?,c#,.net,macos,msbuild,C#,.net,Macos,Msbuild,我有一个针对项目文件中多个框架的库 netstandard1.1;netstandard2.0;网络45 但是,在macOS上运行它时,我会遇到以下错误,因为macOS上没有安装NETFramework 4.5 /usr/local/share/dotnet/sdk/3.1.403/Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3644: The reference assemblies for .NETFramework

我有一个针对项目文件中多个框架的库


netstandard1.1;netstandard2.0;网络45
但是,在macOS上运行它时,我会遇到以下错误,因为macOS上没有安装NETFramework 4.5

/usr/local/share/dotnet/sdk/3.1.403/Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.8 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [/Users/x.x/Repos/kevbite/CompaniesHouse.NET/src/CompaniesHouse.Tests/CompaniesHouse.Tests.csproj]
/usr/local/share/dotnet/sdk/3.1.403/Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.8 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [/Users/x.x/Repos/kevbite/CompaniesHouse.NET/src/CompaniesHouse.IntegrationTests/CompaniesHouse.IntegrationTests.csproj]
/usr/local/share/dotnet/sdk/3.1.403/Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [/Users/x.x/Repos/kevbite/CompaniesHouse.NET/src/CompaniesHouse/CompaniesHouse.csproj]

如何仅构建与计算机上安装的内容兼容的项目?因为我无法为macOS获得net45。

您将无法编译针对4.5和3.1的内容! 从3到4有突破性的变化(我没有检查)

但不管怎样,也许你真的很幸运,把它改成net31就行了,我对此表示怀疑

您可以通过mono尝试intall dotnet 45:


这在安装了所有框架目标的Windows上运行得非常好,并且此库中的框架之间没有破坏性的更改。我会尝试一下Mono,但理想情况下,我只想在没有额外框架的情况下使用它。您可以分别调用
netstandard1.1
netstandard2.0
,使用
-f
选项并跳过
net45