43 visual-studio-2017 visual-studio-2017-build-tools
最后一次Windows更新打破了整个构建链,我对它的原因有点不知所措.
我有一个遗留项目,这是一个带有大量项目的VS 2017解决方案(winform,基于Web,仅限一些Webapi).
当地的事情很完美.我可以建立它们.
在服务器上,proejct已经开始失败,错误是:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186,5): Error : Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186,5): Error : Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186,5): Error : Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.
Process 'msbuild.exe' exited with code '1'.
Run Code Online (Sandbox Code Playgroud)
我已经添加了
<RuntimeIdentifiers>win</RuntimeIdentifiers>
Run Code Online (Sandbox Code Playgroud)
到了很多项目.没变.我很茫然,因为错误信息甚至没有告诉我哪个项目.
Señ*_*Mas 77
在尝试构建之前的某个时刻,您需要删除obj文件夹.不止一个人表明了解决问题的方法.
oza*_*mut 20
我在 Vs 2019 (16.8.6) 中遇到了同样的错误,以下步骤解决了我的问题。
注意,如果bin文件夹存在,只删除obj文件夹是不行的,还需要删除bin文件夹。
Out*_*ill 15
尽管@SeñorCMasMas的回答过去对我有所帮助,但我现在发现(由于安装了.NET Core SDK v2.2-dunno,如果有关系的话),我还需要关闭并重新打开Visual Studio。所以对我来说,配方是:
obj
夹.vs
文件夹(可选,如果出现红线,但显示正确)llo*_*all 15
或者,您只需在项目的根目录中运行 PowerShell 中应该以管理员身份运行的脚本。
Get-ChildItem .\ -include bin,obj -Recurse | foreach { remove-item $_.fullname -Force -Recurse }
Run Code Online (Sandbox Code Playgroud)
此脚本将删除所有 obj 和 bin 文件夹
Bah*_*haa 11
将此添加<RuntimeIdentifier>win</RuntimeIdentifier>
到您的项目文件中,例如在element之后TargetFrameworkVersion
。确保元素名称为单数。RuntimeIdentifiers
另一方面以新的csproj格式使用
通过运行手动恢复包时,在使用 packageReference 的项目中遇到此问题
NuGet.exe restore my.sln
Run Code Online (Sandbox Code Playgroud)
作为 TeamCity 构建的一部分(因此可能与 nf313743 的答案相关/sf/answers/4266584871/),然后使用 msbuild 构建项目。当 msbuild 开始处理 PackageReference 时,这将导致以下错误:
[ResolveNuGetPackageAssets] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186, 5):
Your project file doesn't list 'win-x86' as a "RuntimeIdentifier". You should add 'win-x86' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.
Run Code Online (Sandbox Code Playgroud)
删除 obj 目录等在这里不起作用,因为它们是通过restore
步骤添加的;添加 RuntimeIdentifier 可能会起作用,但在 VS2017 命令行上构建完全相同的内容可以正常工作,因此很明显,区别在于 TeamCity 设置环境的方式。
罪魁祸首可以在第一次调用的输出中找到:
NuGet.exe restore my.sln -NonInteractive
MSBuild auto-detection: using msbuild version '16.10.2.30804'
from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin'.
Run Code Online (Sandbox Code Playgroud)
它使用 VS2019 安装中的 msbuild,而该项目是由 VS2017 构建的,因此在混合这些内容时会出现不兼容性,这并不意外。不管怎样,关键是 TeamCity 可能没有像 VS2017 命令行那样设置完整的环境,并且 NuGet 文档说
By default the MSBuild in your path is picked,
otherwise it defaults to the highest installed version of MSBuild.
Run Code Online (Sandbox Code Playgroud)
这就是为什么它使用 VS2019 的原因。解决方案是手动传递-MsBuildPath
给 NuGet 并将其设置为与 teamCity 中所选构建工具对应的内容,在本例中:
NuGet.exe -msBuildPath "%MSBuildTools15.0_x86_Path%" restore my.sln
Run Code Online (Sandbox Code Playgroud)
(事实证明 teamCity 本身在其自己的 NuGet 步骤中也受到此问题的困扰:How to set the MSBuild version for TeamCity NuGet Installer?)
我有类似的问题。我的错误是
错误:您的项目文件未将“win10”列为“运行时标识符”。您应该将“win10”添加到项目文件中的“RuntimeIdentifiers”属性,然后重新运行 NuGet 还原。
好吧,事实证明我只需将构建目标从“任何 CPU”更改为其他内容(例如 x64)...
我有一个类似的案例。我尝试通过 msbuild 构建解决方案,而不安装 Visual Studio 2017,只需安装最新版本的 vs 2017 构建工具。这是我的步骤:
您的项目文件未将“win”列为“RuntimeIdentifier”。您应该将“win”添加到项目文件中的“RuntimeIdentifiers”属性,然后重新运行 NuGet 还原。
这似乎是旧版本 Nuget 中的一个问题。请参考这里。最后,我通过使用最新的Nuget(v5.0.2)恢复包解决了这个问题。步骤:
归档时间: |
|
查看次数: |
15053 次 |
最近记录: |