I am trying to run MSBuild via a command line and cannot get the NuGet packages to restore using the /t:restore switch as documented here.. The solution is a fairly simple ASP.NET MVC app and a MSTest project. If I run the restore flag on either my local dev folder or from the build server I see no NuGet packages being restored, even if I delete the packages, obj, and bin folders.
I have enabled auto download as documented here. If I open the project with Studio and build it the packages are restored as expected. This only fails when MSBuild is being used.
This is all being done with Visual Studio 2017 at the latest patch level. The build machine has Professional, my machine has Enterprise. Both have the same behavior.
Has anyone gotten MSBuild to restore NuGet packages using MSBuild 15.1?
C:\Users\me\Documents\Visual Studio 2017\Projects\cmbs-admin>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe" /t:Restore
Microsoft (R) Build Engine version 15.1.1012.6693
Copyright (C) Microsoft Corporation. All rights reserved.
Building the projects in this solution one at a time. To enable parallel build, please add the "/m"switch.
Build started 6/22/2017 2:01:57 PM.
Project "C:\Users\me\Documents\Visual Studio 2017\Projects\MyProject\MyProject.sln" on node
1 (Restore target(s)).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
Restore:
Restoring packages for C:\Users\me\Documents\Visual Studio 2017\Projects\MyProject\MyProject.Tests\MyProject.Tests.csproj...
Restoring packages for C:\Users\me\Documents\Visual Studio 2017\Projects\MyProject\MyProject\MyProject.csproj...
Committing restore...
Committing restore...
Lock file has not changed. Skipping lock file write. Path: C:\Users\me\Documents\Visual Studio 2017\Projects\MyProject\MyProject\obj\project.assets.json
Lock file has not changed. Skipping lock file write. Path: C:\Users\me\Documents\Visual Studio 2017\Projects\MyProject\MyProject.Tests\obj\project.assets.json
Restore completed in 350.01 ms for C:\Users\me\Documents\Visual Studio 2017\Projects\MyProject\MyProject\MyProject.csproj.
Restore completed in 349.87 ms for C:\Users\me\Documents\Visual Studio 2017\Projects\MyProject\MyProject.Tests\MyProject.Tests.csproj.
NuGet Config files used:
C:\Users\me\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
Feeds used:
https://api.nuget.org/v3/index.json
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Done Building Project "C:\Users\me\Documents\Visual Studio 2017\Projects\MyProject\MyProject.sln" (Restore target(s)).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.18
C:\Users\me\Documents\Visual Studio 2017\Projects\MyProject>
NuGet.exe restore
is still the option for non-.NET Core projects. – Lex Li