【问题标题】:Build Visual Studio 2015 Solution with MSBuild 12使用 MSBuild 12 构建 Visual Studio 2015 解决方案
【发布时间】:2015-08-17 16:50:35
【问题描述】:

我正在尝试使用 MSBuild 扩展在 Jenkins 上构建解决方案。我已将解决方案从 VS 2013 迁移到 VS 2015。为了能够在 Visual Studio 2015 中恢复 NuGet 包,我必须按照此处的建议删除 .nuget 文件夹:http://docs.nuget.org/consume/package-restore/migrating-to-automatic-package-restore

现在的问题是 MSBuild 需要 .nuget 文件夹才能恢复 nuget 包。

Build FAILED.

"E:\_JENKINS\workspace\Project1 - Deploy DEVELOP to BuildServer\Solution1\Build\Build.proj" (DeployTarget target) (1) ->
E:\_JENKINS\workspace\Project1 - Deploy DEVELOP to BuildServer\Solution1\Build\Build.proj(50,5): 
error MSB4019: The imported project "E:\_JENKINS\workspace\Project1 - Deploy DEVELOP to BuildServer\Solution1\.nuget\NuGet.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

0 Warning(s)
1 Error(s)

我把事情搞混了吗?我做错了什么吗?
因为只有一个有效:MSBuild 或 Studio Package Restore。

所以要么我将包文件夹添加到 git,要么通过命令行恢复或 MSBuild 恢复替换解决方案中的自动恢复。但无论如何,这两种解决方案似乎都是错误的。

【问题讨论】:

  • 只需从项目文件 (csproj) 中删除对该目标文件的引用,然后在编译前使用 nuget restore solution.sln 恢复包。 NuGet 文档有更多关于这种迁移的信息。

标签: jenkins msbuild visual-studio-2015 nuget-package-restore


【解决方案1】:

NuGet 包还原的工作方式在 Visual Studio 2013 和 2015 之间发生了变化。

构建过程的第一步需要直接调用 NuGet.exe,例如:

nuget restore solution.sln

我将 NuGet.exe 放在构建机器的 PATH 中。

您应该在控制台(或管道步骤日志)中看到正在恢复的包。

如果没有,您可能需要查看 Jenkins 代理设置,具体取决于您的 Jenkins 在网络上相对于互联网的位置。在过去,我不得不请求一个对 nuget.org/* 具有“特权”访问权限的服务帐户

一旦所有包都已恢复,您应该会在 Jenkins 工作区中看到一个 packages/ 文件夹作为解决方案文件的兄弟。

然后您可以依次使用 /t:Clean 和 /t:Rebuild 调用 MSBuild,并期望通过 NuGet 包步骤。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-18
    • 2015-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多