我正在尝试建立一个同时针对.NET 4.5.1和.NET Standard 1.3的类库。根据the documentation,我应该能够做到这一点:
<PropertyGroup>
<TargetFrameworks>net451;netstandard1.3</TargetFrameworks>
</PropertyGroup>
但是,当我尝试构建时,出现以下奇怪错误:Cannot infer TargetFrameworkIdentifier and/or TargetFrameworkVersion from TargetFramework='net451'. They must be specified explicitly.
MSB3645 .NET Framework v3.5 Service Pack 1 was not found. In order to target ".NETFramework,Version=v1.3", .NET Framework v3.5 Service Pack 1 or later must be installed.
MSB3644 The reference assemblies for framework ".NETFramework,Version=v1.3" 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.
如果我手动指定目标框架标识符,它会很好地构建:
<PropertyGroup>
<TargetFrameworks>net451;netstandard1.3</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net451'">
<TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
<TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>
</PropertyGroup>
我正在使用Visual Studio 2017社区。我在这里做错什么了吗?
最佳答案
您是否确实编写了<TargetFrameworks>net451;netstandard1.3</TargetFrameworks>
而不是<TargetFramework>net451;netstandard1.3</TargetFramework>
?
在添加缺少的s
之前,我遇到了同样的错误
关于.net - 在csproj文件中多目标时生成错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43072097/