本文介绍了命令“C:\Main\Src\.nuget\nuget.exe restore -SolutionDirectory ..\"退出代码 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个多星期以来,我一直在努力让 NuGet 正常工作.我终于让它在本地构建上工作,但不能在 TFS 2013 构建上工作.我将范围缩小到在团队构建期间不会发生 NuGet,但是当我添加

I've been struggling with getting NuGet to work for well over a week now. I finally got it to work on local builds, but not on TFS 2013 builds. I narrowed it down to NuGet not happening during team builds, but then when I added

$(SolutionDir).nuget\nuget.exe restore -SolutionDirectory ..\

到构建顺序中我的第一个项目的预构建事件,我收到此错误.如果我从解决方案目录中的命令行执行该命令,它工作正常.它在本地构建良好,但在构建服务器上我收到此代码 1"错误.非常有帮助 Grrrrr!因此,我在构建之前打开了 TFS 获取的源代码,并尝试在构建服务器上进行本地构建,但出现相同的错误(即使它在我的本地机器上运行良好).我尝试在团队构建中增加冗长,但这只是显示相同的错误.抱歉 - 我在谷歌上搜索了这个错误并找到了很多回复,但没有任何帮助......

to the pre-build event on my first project in the build order and I get this error. And if I execute that command from the command line in the solution directory it works fine.It builds locally fine, but on the build server I get this "code 1" error. Very helpful Grrrrr! So I opened the source that TFS gets before the build and tried to doing a local build on the builds server and I get the same error (even though it works fine on my local machine). I tried increased verbosity on the team build but that just shows the same error. Sorry - I've googled this error and found many responses, but nothing that has helped...

顺便说一句,当我在解决方案中运行 nuget.exe 版本时,它的版本是 3.4.3.855.

BTW, when I run the version of nuget.exe in the solution it's version 3.4.3.855.

推荐答案

要使用 TFS XAML 构建恢复 NuGet 包,请尝试按照以下步骤操作:

To enable restore NuGet package with TFS XAML build, please try to follow below steps:

  1. 在 VS IDE 中,转到 工具 -> 选项 -> NuGet 包管理器 -> 启用允许 NuGet 下载丢失的包.
  2. 从 .nuget 文件夹中删除 NuGet.exe 和 NuGet.targets 文件.确保这两个文件也从版本控制中删除.
  3. 从 .proj 文件中删除以下标签:
  1. In VS IDE, go to Tools -> Options -> NuGet Package Manager -> enable Allow NuGet to download missing packages.
  2. Delete NuGet.exe and NuGet.targets files from .nuget folder. Be sure these two files are deleted from version control as well.
  3. Remove the following tags from .proj file:
    1. <RestorePackages>true</RestorePackages>

    2.<Import Project="$(SolutionDir)\.nuget\nuget.targets" />

    3. <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
        <PropertyGroup>
            <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information,
    see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
        </PropertyGroup>
        <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
    </Target>

更多细节请参考这个分步教程:使用 TFS 自动恢复 Nuget 包以正确的方式构建

More details please refer this step by step tutorial:Auto restore Nuget packages with TFS Build the right way

这篇关于命令“C:\Main\Src\.nuget\nuget.exe restore -SolutionDirectory ..\"退出代码 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 00:26