在 csproj 文件中多目标时构建错误
Build errors when multi-targeting in csproj file
我正在尝试构建一个 class 库,它同时面向 .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
之前,我一直遇到同样的错误
我正在尝试构建一个 class 库,它同时面向 .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