0

In my asp.net web application, i have solution with 5 projects and nuget.org. In TFS Build Definition,

1) While building the whole solution in Visual Studio Build Task

         Nuget packages getting restored.    

2) While trying to generate executable files for individual projects in MS Build Task

If I select Restore Nuget packages, It's not finding nuget packages and step getting failed with message - "Process 'NuGet.exe' exited with code '1'."

I have tried many references online and none worked. Any suggestions on how to solve this?
Do i need to make any changes in the nuget.config file to support restoring
packages to individual projects.

Albert Einstein
  • 7,472
  • 8
  • 36
  • 71
Gauty
  • 47
  • 2
  • 7
  • Hi Gauty, `If i select Restore Nuget packages` did this mean you have selected the **Restore NuGet Packages** option in Advanced of the MSBuild Task configuration? – PatrickLu-MSFT Jan 30 '18 at 09:07
  • @PatrickLu-MSFT Yes, I have selected the option in Advanced Dropdown. My build definition steps in order: 1) Nuget Installer, 2) Visual Studio Build task for whole solution, 3) Four MS Build Tasks to generate publish files for individual projects. The visual studio build task is able to restore the nuget packages, but not the same in the case of MS build tasks, where it uses individual projects. – Gauty Jan 30 '18 at 14:17
  • First uncheck the "Restore Nuget pacakges" option in Advanced dropdown, since you have used Nuget installer task already. What's the result if you move Visual Studio Build task only use MS build tasks? – PatrickLu-MSFT Jan 30 '18 at 15:29
  • When i uncheck the "Restore Nuget pacakges" in MSBuild task to generate publish files for an individual project, the build is getting succeeded. But, when i post those files to server, the events are not getting logged in to the database. I have figured out the bin files created in visual studio build and MS build are of different size. When i uncheck "Restore Nuget pacakges" in visualstudioBuild task, it's creating bin files similar to MSBuild. Hence, i have noticed that the package restore is not happening in the MSBuild Task and causing the issue – Gauty Jan 30 '18 at 17:56
  • @PatrickLu-MSFT, I have just restored packages from nuget.org with nuget installer step. But, we have custom packages too. we used to restore the custom packages by updating a URI in package manager console. But, the build server could not find those custom packages when an TFS build is triggered. I have browsed online on how to update custom packages on build machine. I have seen that we can update package sources in Nuget.Config file, or update using powershell script in build definition. Could you please suggest me, what's the recommended way to update custom packages on a build machine – Gauty Feb 02 '18 at 16:37

2 Answers2

2

Do not directly select Restore Nuget pacakges in MS build task configuration. This option is deprecated. To restore NuGet packages, add a NuGet Installer step before the build.

(Important) This option is deprecated. Make sure to clear this checkbox and instead use the NuGet Installer build step.

Source Link: MSBuild

Besides, you could also build single project not the entire solution in Visual Studio Build task. Just select the project (.*proj) files instead of .sln file. Unless you are building a customized MSBuild project file, then we recommend you use the MSBuild step instead of the Visual Studio Build step.

You could also try to build single project using Visual Studio Build task, see if the issue is still exists.

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • I have tried visualStudioBuild task for .*proj file instead of MS Build task. Still if i check the option "Restore Nuget Packages", it's getting failed. SInce, the nuget can be found under solution and not in this individual project, it's unable to find the packages to restore. Do i need to make any changes in nuget.org or nuget.targets to utilize nuget in individual projects rather than just solution. – Gauty Jan 30 '18 at 19:36
0

Same problem, downgraded to 4.4.1. it helped