问题
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 ..\
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...
BTW, when I run the version of nuget.exe in the solution it's version 3.4.3.855.
回答1:
To enable restore NuGet package with TFS XAML build, please try to follow below steps:
- In VS IDE, go to Tools -> Options -> NuGet Package Manager -> enable Allow NuGet to download missing packages.
- Delete NuGet.exe and NuGet.targets files from .nuget folder. Be sure these two files are deleted from version control as well.
- 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>
More details please refer this step by step tutorial:Auto restore Nuget packages with TFS Build the right way
来源:https://stackoverflow.com/questions/45680811/the-command-c-main-src-nuget-nuget-exe-restore-solutiondirectory-exited