c# - 我如何只构建与机器上安装的项目兼容的项目?
问题描述
我有一个针对项目文件中多个框架的库。
<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。
解决方案
您将无法使用 3.1 编译针对 4.5 的内容!从 3 到 4 有重大变化(我没有检查)。
但无论如何,也许你真的很幸运,只需将其更改为 net31 即可,我对此表示怀疑。
您可以通过单声道尝试安装 dotnet 45:
推荐阅读
- postman - Blazor Server Webapi 不适用于邮递员
- java - 将一个类的对象传递给另一个类而不导入?
- windows - 致命:错误的修订版 '$GIT_COMMIT''
- windows - 在批处理文件的for循环中使用wmic命令中的变量
- postgresql - plpgsql 函数是原子的吗?
- plsql - 在 SQL 或 PLSQL 中将当前时间四舍五入到下一个 15 分钟间隔
- javascript - Window.open 脚本管理器正在打开 2 页
- r - 在 AWS 上托管的闪亮应用程序中保护代码和数据
- flutter - GoogleMapsFlutter 使用 LatLngBounds 将相机更新到子区域
- java - 通过注释 Kotlin 限制参数中的值