简体   繁体   English

元素中的属性“版本”<PackageReference> 不被承认

[英]The attribute "Version" in element <PackageReference> is unrecognized

I have a solution with many projects that target .net 4.6.1.我有许多针对 .net 4.6.1 的项目的解决方案。 On our MS build server it builds just fine.在我们的 MS 构建服务器上,它构建得很好。 I recently added a project that targets .NET Standard 1.3.我最近添加了一个针对 .NET Standard 1.3 的项目。 This will not build on the build server.这不会在构建服务器上构建。 It builds locally with VS2017 just fine.它在本地使用 VS2017 构建就好了。 Build server VS has just been updated with all the latest.构建服务器 VS 刚刚更新了所有最新版本。

The build error I'm getting is: The attribute "Version" in element <PackageReference> is unrecognized.我得到的构建错误是: The attribute "Version" in element <PackageReference> is unrecognized.

I am getting this for a few references.我得到这个作为一些参考。 Here's one pulled from the project file: <PackageReference Include="System.Diagnostics.Process" Version="4.3.0"/>这是从项目文件中提取的一个: <PackageReference Include="System.Diagnostics.Process" Version="4.3.0"/>

Any ideas?有任何想法吗?

Looks like you are not building using the MSBuild.exe that is included in VS 2017 (/ build tools) but rather the MSBuild.exe that ships with .NET Framework, which is an old version (and won't be updated).看起来您没有使用 VS 2017(/构建工具)中包含的 MSBuild.exe 进行构建,而是使用 .NET Framework 附带的 MSBuild.exe,这是一个旧版本(不会更新)。

Consider using VSWhere to locate MSBuild.exe考虑使用VSWhere定位MSBuild.exe

If anyone come across this thread, refer below solution for .Net Framework projects.如果有人遇到此线程,请参阅以下 .Net Framework 项目的解决方案。

<PackageReference Include="System.Diagnostics.Process">
    <Version>4.3.0</Version>
</PackageReference>

I was getting that same build error message using NuGet Version: 3.4.4.1321我使用NuGet 版本收到相同的构建错误消息:3.4.4.1321

I ran nuget update -self我跑了nuget update -self

Checking for updates from https://www.nuget.org/api/v2/.
Currently running NuGet.exe 3.4.4-rtm-1321.
Updating NuGet.exe to 5.1.0.
Update successful.

and afterwards there was no longer a build error when I ran nuget然后当我运行 nuget 时不再有构建错误

The right version of MSBuild is needed to build a project file with package references with version attribute.需要正确版本的 MSBuild 来构建具有版本属性的包引用的项目文件。 From Team City this screen shot shows an example.来自 Team City 的此屏幕截图显示了一个示例。 Note the name, 'Microsoft Build Tools 2017'.请注意名称“Microsoft Build Tools 2017”。 This is the package you want to have on your developer PC or target server.这是您希望在开发人员 PC 或目标服务器上拥有的软件包。

Team City - 选择 MSBuild 版本

This will be helpful for the CI /devops / build people out there that needs to build .NET applications / other apps requiring MSbuild on a build server.这对于需要在构建服务器上构建 .NET 应用程序/其他需要 MSbuild 的应用程序的 CI /devops / 构建人员很有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 元素中的“包含”属性<packagereference>无法识别</packagereference> - The attribute "Include" in element <PackageReference> is unrecognized 加载csproj元素中的属性“ExcludeAssets”<packagereference> 无法识别</packagereference> - Load csproj The attribute “ExcludeAssets” in element <PackageReference> is unrecognized PackageReference 条目中的 Version 属性是否有任何有意义的区别? - Is there any meaningful difference where the Version attribute is in a PackageReference entry? 删除元素的定制配置无法识别的属性 - Custom configuration unrecognized attribute for remove element update-package 运行时约束 PackageReference 升级版本 - Constrain PackageReference upgrade version when update-package run 发布 Nuget 包时有关 PackageReference 版本的最佳实践? - Best practice regarding PackageReference version when publishing Nuget packages? 使用 PackageReference 时如何控制安装的依赖版本 - How control what depenent version is installed when using PackageReference 工具版本“15.0”无法识别 - The tools version “15.0” is unrecognized 无法识别的属性“defaultAlgorithmSuite” - Unrecognized attribute 'defaultAlgorithmSuite' 无法识别的元素 unitTestProvider - Unrecognized element unitTestProvider
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM