1

I want to enable NuGet package manager through the command line but I am not sure how to do it.

We have a Jenkins pipeline that installs MSBuild15 BuildTools (using choco commands) and I need to enable NuGet package manager as part of the automated script.

If I enable it directly on the server/agent then the compilation of the solution is successful but I need to automate this step.

I have attached an image of what it looks like through vs_installer -> Image of VS Installer, what i need to enable through command line

  • Are you sure this is "enabling" NuGet and not simply adding nuget.exe to a directory that's covered by your PATH? You can find the NuGet executables (not installers, full executables) here: https://www.nuget.org/downloads Try dropping one of these into a folder that's covered by your PATH environment variable. – Joe Cullinan Feb 04 '20 at 18:18
  • @JoeCullinan when we don't enable NuGet a "Clean" of the solution fails with the following error; _CoreClean: Creating directory "obj\Release\". C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1657,5): error MSB4036: The "GetReferenceNearestTargetFrameworkTask" task was not found._ According to this document the answer is to enable "NuGet package manager" [link](https://stackoverflow.com/questions/47797510/the-getreferencenearesttargetframeworktask-task-was-not-found) after I done this the clean & build worked. – Conor Griffin Feb 05 '20 at 10:51
  • @JoeCullinan I want to enable this feature through the command line automatically. – Conor Griffin Feb 05 '20 at 10:53

1 Answers1

0

This should work in Powershell:

Start-Process "C:\Program Files (x86)\Microsoft Visual Studio\vs_installer.exe" -ArgumentList 'modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools" --quiet --add Microsoft.VisualStudio.Component.NuGet.BuildTools --add Microsoft.Net.Component.4.5.TargetingPack --norestart --force' -Wait -PassThru

Found here: https://developercommunity.visualstudio.com/content/problem/137779/the-getreferencenearesttargetframeworktask-task-wa.html#reply-160786

Joe Cullinan
  • 552
  • 3
  • 15