在 csproj 文件中进行多目标时生成错误

编程入门 行业动态 更新时间:2024-10-27 08:28:18
本文介绍了在 csproj 文件中进行多目标时生成错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试构建一个同时面向 .NET 4.5.1 和 .NET Standard 1.3 的类库.根据 文档,我应该可以做到这一点:

I'm trying to build a class library that multi-targets both .NET 4.5.1 and .NET Standard 1.3. According to the documentation, I should be able to do this:

<PropertyGroup> <TargetFrameworks>net451;netstandard1.3</TargetFrameworks> </PropertyGroup>

但是,当我尝试构建时,我得到了这些奇怪的错误:

However, when I try to build, I get these odd errors:

无法从 TargetFramework='net451' 推断 TargetFrameworkIdentifier 和/或 TargetFrameworkVersion.必须明确指定它们.

Cannot infer TargetFrameworkIdentifier and/or TargetFrameworkVersion from TargetFramework='net451'. They must be specified explicitly.

MSB3645 .NET Framework v3.5 Service Pack 1 未找到.为了定位.NETFramework,Version=v1.3",必须安装 .NET Framework v3.5 Service Pack 1 或更高版本.

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 框架.NETFramework,Version=v1.3"的参考程序集没有找到.要解决此问题,请为此框架版本安装 SDK 或 Targeting Pack,或者将您的应用程序重新定位到已安装 SDK 或 Targeting Pack 的框架版本.请注意,程序集将从全局程序集缓存 (GAC) 中解析,并将用于代替引用程序集.因此,您的程序集可能无法正确定位于您想要的框架.

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.

如果我手动指定目标框架标识符,它构建得很好:

If I specify the target framework identifiers manually, it builds fine:

<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 社区.我在这里做错了吗?

I'm using Visual Studio 2017 Community. Am I doing something wrong here?

推荐答案

你确定写了吗

<TargetFrameworks>net451;netstandard1.3</TargetFrameworks>

而不是

<TargetFramework>net451;netstandard1.3</TargetFramework>

?

在添加缺少的 s

更多推荐

在 csproj 文件中进行多目标时生成错误

本文发布于:2023-11-05 19:27:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1561650.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   目标   文件   csproj

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!