简体   繁体   中英

The attribute "Version" in element <PackageReference> is unrecognized

I have a solution with many projects that target .net 4.6.1. On our MS build server it builds just fine. I recently added a project that targets .NET Standard 1.3. This will not build on the build server. It builds locally with VS2017 just fine. Build server VS has just been updated with all the latest.

The build error I'm getting is: 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"/>

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).

Consider using VSWhere to locate MSBuild.exe

If anyone come across this thread, refer below solution for .Net Framework projects.

<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

I ran 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

The right version of MSBuild is needed to build a project file with package references with version attribute. From Team City this screen shot shows an example. Note the name, 'Microsoft Build Tools 2017'. This is the package you want to have on your developer PC or target server.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM