我们的开发人员之一创建了一个项目,该项目在其PC上使用Visual Studio 2017成功构建。我想从Azure管道上的Azure虚拟机上构建项目。由于它将来自管道,因此我无法使用Visual Studio UI。因此,我正在尝试先从命令行构建它,如果有效,我将添加一个管道任务来完成。
该项目使用Nuget安装一些MongoDB软件包。这种并发症首先使故障排除混淆了,因为它似乎是一个杂货问题,但事实并非如此。
第一个问题:
"C:\workspace\xxxxx\xxxxx.sln" (default target) (1) ->
"C:\workspace\xxxxx\xxxxx.csproj" (default target) (2) ->
C:\workspace\xxxxx\packages\MongoDB.Libmongocrypt.1.0.0\build\MongoDB.Libmongocrypt.targets(4,16):
error MSB4186: Invalid static method invocation syntax: "MSBuild]::IsOsPlatform('Windows')".
Method '[MSBuild]::IsOsPlatform' not found. Static method invocation should be of the form:
$([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)).`
我在网上找不到有关此错误消息的信息,但是在阅读了我发现的内容之后(例如,此,听起来我可能需要更新msbuild。
- ” >
- /csharp-3640“ rel =“ nofollow noreferrer 该构建未成功:版本15.1.155
来自 ,或者我选择更新整个vs 2017的应用程序。
结论是,尝试自行更新MSBUILD 。
-WS2016 错误消失了。第一个问题解决了。
第二个问题:
构建仍然失败,但错误的错误。
"C:\workspace\xxxxx\xxxxx.sln" (default target) (1) ->
"C:\workspace\xxxxx\xxxxx.csproj" (default target) (2) ->
(GetReferenceAssemblyPaths target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\
bin\Microsoft.Common.CurrentVersion.targets(1179,5):
error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.7.2" 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.
[C:\workspace\xxxxxx\xxxxx.csproj]
如何解决第二个构建错误?
附加数据
命令 ls c:\ program Files(x86)\ Reference Assemblies \ Microsoft \ Framework
列出了最新的框架为v4.6.1,v4.6.2,v4.7.7.1和v4.x,由于我的VS2017更新,今天所有时间戳记。
我从官方网站上下载了Microsoft .NET Framework v4.7.2设置, ndp472-kb4054531-web.exe 。当我尝试运行它时,我得到了一个阻塞的安装,其原因”。网络框架4.7.2或以后的更新已在此计算机上安装。”
One of our developers has created a project which builds successfully using Visual Studio 2017 on his PC. I want to build the project on an Azure virtual machine, from an Azure Pipeline. Since it will be from a pipeline, I cannot use the Visual Studio UI. So I'm trying to build it from the command line first, and if that works, I will add a pipeline task to do it.
This project uses NuGet to install some MongoDB packages. This complication confused the troubleshooting at first, because it appeared to be a MongoDB issue, but it is not.
First problem:
"C:\workspace\xxxxx\xxxxx.sln" (default target) (1) ->
"C:\workspace\xxxxx\xxxxx.csproj" (default target) (2) ->
C:\workspace\xxxxx\packages\MongoDB.Libmongocrypt.1.0.0\build\MongoDB.Libmongocrypt.targets(4,16):
error MSB4186: Invalid static method invocation syntax: "MSBuild]::IsOsPlatform('Windows')".
Method '[MSBuild]::IsOsPlatform' not found. Static method invocation should be of the form:
$([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)).`
I could not find much information online about this error message, but after reading what I did find (for example, this MongoDB Jira entry, it sounded like I might need to update MSBuild.
- MSBuild on the PCs where the build was successful: version 15.9.21.
- MSBuild on the VM where the build was not successful: version 15.1.155
From this StackOverflow thread, I concluded that it was dangerous to try updating MSBuild by itself, or to take a piecemeal approach. I chose to update the entire VS 2017 application.
The Azure VM is a self-hosted Standard DS3 v2 machine, with the plan VS-2017-Ent-WS2016. It came with VS 2017 installed. I went to Windows "Features and Applications", selected VS 2017, and updated the entire application from there.
Now MSBuild on the Azure VM is version 15.9.21. The error goes away. First problem solved.
Second problem:
The build still fails, but with a different error.
"C:\workspace\xxxxx\xxxxx.sln" (default target) (1) ->
"C:\workspace\xxxxx\xxxxx.csproj" (default target) (2) ->
(GetReferenceAssemblyPaths target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\
bin\Microsoft.Common.CurrentVersion.targets(1179,5):
error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.7.2" 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.
[C:\workspace\xxxxxx\xxxxx.csproj]
How do I fix this second build error?
Additional data
The command ls C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework
lists the newest frameworks as v4.6.1, v4.6.2, v4.7.1, and v4.X, all timestamped today, as a result of my VS2017 update.
I downloaded the Microsoft .NET Framework v4.7.2 Setup, ndp472-kb4054531-web.exe, from the official website. When I attempted to run it, I got a blocked installation, with the reason ".NET Framework 4.7.2 or a later update is already installed on this computer."
发布评论
评论(1)
解决错误:
下载/安装 4.7.7.2 sdk 包含目标包。另请参见安装.NET Framework开发人员包或定位包
这里还有其他一些可能有用的资源:
To fix the error:
download/install the 4.7.2 SDK which contains the targeting pack. Also see To install the .NET Framework Developer Pack or Targeting Pack
Here are some other resources that may be useful: