尝试构建针对net47而不是.netcore或.net std的Microsoft.NET.Sdk样式项目时. dotnet版本将给出有关缺少定位包的错误. msbuild可以代替,但是我更喜欢使用dotnet构建.有办法吗
/usr/local/share/dotnet/sdk/2.1.200/Microsoft.Common.CurrentVersion.targets
(1179,5): error MSB3644: The reference assemblies for framework
".NETFramework,Version=v4.7" were not found. To resolve this, install the
SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or
Targeting Pack installed. Note that assemblies will be resolved from the
Global Assembly Cache (GAC) and will be used in place of reference
assemblies. Therefore your assembly may not be correctly targeted for the
framework you intend.
解决方法:
是.可以使用nuget提取定位包.然后添加框架路径覆盖.如果目标框架是.NET v4.7,则可以将其添加到Microsoft.NET.Sdk .csproj / .fsproj的任何地方.
<PropertyGroup Condition="'$(OS)' != 'Windows_NT' AND '$(TargetFramework)'== 'net47'">
<!-- Make .NET 4.7 reference assemblies available even on Linux -->
<FrameworkPathOverride>$(NuGetPackageRoot)microsoft.targetingpack.netframework.v4.7/1.0.1/lib/net47/</FrameworkPathOverride>
<!-- Make sure the additional feed is searched. -->
<RestoreAdditionalProjectSources>https://dotnet.myget.org/F/dotnet-core/api/v3/index.json</RestoreAdditionalProjectSources>
</PropertyGroup>
<ItemGroup Condition="'$(OS)' != 'Windows_NT' AND '$(TargetFramework)'== 'net47'">
<!-- Make sure the reference assemblies are available -->
<PackageReference Include="Microsoft.TargetingPack.NETFramework.v4.7"
Version="1.0.1" ExcludeAssets="All" PrivateAssets="All" />
</ItemGroup>
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!