首页 > 解决方案 > 我如何只构建与机器上安装的项目兼容的项目?

问题描述

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

  <PropertyGroup>
    <TargetFrameworks>netstandard1.1;netstandard2.0;net45</TargetFrameworks>
  </PropertyGroup>

但是,在 macOS 上运行它时,我收到以下错误,因为 NETFramework 4.5 未安装在 macOS 上。

/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。

标签: c#.netmacosmsbuild

解决方案


您将无法使用 3.1 编译针对 4.5 的内容!从 3 到 4 有重大变化(我没有检查)。

但无论如何,也许你真的很幸运,只需将其更改为 net31 即可,我对此表示怀疑。

您可以通过单声道尝试安装 dotnet 45:

有没有办法在 Mac OS X 上安装 .net framework 4.5.2 或更高版本?


推荐阅读