【问题标题】:NuGet update fails, does not seem to pick up VisualStudioVersion properly?NuGet 更新失败,似乎没有正确获取 VisualStudioVersion?
【发布时间】:2014-04-30 14:39:40
【问题描述】:

Windows 2012 R2 构建服务器、TeamCity 8.1.2、nuget.exe 2.8.1

在启用并测试涉及常规完整构建清理和 NuGet 还原的构建配置后,我们启用了增量 VCS 更新,并在我们的构建配置上启用了 NuGet 更新。在 NuGet 更新期间,构建配置现在失败并出现此错误:

[Step 1/4] update: Updating NuGet packages for OurSolutionName.sln
[22:20:10]NuGet command: D:\TeamCity\buildAgent\tools\NuGet.CommandLine.DEFAULT.nupkg\tools\NuGet.exe update D:\TeamCity\buildAgent\work\52034b1c4c1ab5f5\OurSolutionName.sln -Verbose -RepositoryPath D:\TeamCity\buildAgent\work\52034b1c4c1ab5f5\packages
[22:20:10]Starting: D:\TeamCity\buildAgent\temp\agentTmp\custom_script9174264003705363137.cmd
[22:20:10]in directory: D:\TeamCity\buildAgent\work\52034b1c4c1ab5f5
[22:20:10]Scanning for projects...
[22:20:10]The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TypeScript\Microsoft.TypeScript.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.  D:\TeamCity\buildAgent\work\52034b1c4c1ab5f5\proofs\MvcRouting\MvcRouting\MvcRouting.csproj
[22:20:11]Process exited with code 1
[22:20:11][Step 1/4] Step Update nuGet packages (NuGet Installer) failed

关键是 MSBuild 路径中的 \v10.0\。我查看了错误中提到的 csproj 文件,它使用标准兼容性逻辑来确定 Visual Studio 版本并适当地设置路径,如果 VisualStudioVersion 为空,则仅回退到 10.0。我检查了解决方案文件,并确认 VisualStudioVersion 为 12:

Microsoft Visual Studio Solution File, Format Version 12.00
Visual Studio 2013
VisualStudioVersion = 12.0.30110.0

任何想法为什么 NuGet 更新似乎没有选择正确的 Visual Studio 版本?

【问题讨论】:

    标签: c# msbuild visual-studio-2013 nuget


    【解决方案1】:

    VisualStudioVersion 将在您从 Visual Studio 中构建时定义。在构建服务器上,默认情况下不会定义它。

    您应该能够通过机器上或 Team City 中的环境变量来设置它。或者只是更新您的项目,使其回退到版本 12。

    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion>
    

    NuGet 不会从解决方案本身读取任何内容。它只是将其用作基本目录,从中可以找到解决方案下任何子目录中存在的任何 packages.config 文件。

    【讨论】:

    • 我试过添加系统环境变量VisualStudioVersion=12.0,结果还是v10.0路径。我还尝试添加 env.VisualStudioVersion ,显然它忽略了十进制值。 :( 我试图避免自己修改项目,但看起来这可能是解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-09
    • 1970-01-01
    • 1970-01-01
    • 2018-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多