0
votes

I'm configuring an existing project (dotnet core) to use private nuget repository. I've setup my project with the structure as follows:

  • Project1
  • Project2
  • Project3
  • .sln
  • nuget.config

I'm able to restore my packages if i'm to run a "dotnet restore" commands but not while using Visual Studio's build (MSBuild).

I would like to be able to restore my package while using Visual Studio's MSBuild.(not using cli)

If possible, i'd like to avoid using msbuild's Exec task to run dotnet restore before build.

  • I've tried them in both Visual Studio 2017 and 2019
1
If you're using msbuild (15.x and 16.x versions), you can use the restore switch when you call the command. The path of the msbuild.exe will always to be: C:\Program Files (x86)\Microsoft Visual Studio\2017\xxx\MSBuild\15.0\Bin or C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin.LoLance

1 Answers

2
votes

You will need to run the MSBuild Restore target before the actual target. MSBuild.exe provides a built-in way to execute this target, then flush all caches (needed to avoid incremental build issues due to freshly restored packages) and then perform the actual build with the the -r (long: -restore) argument:

e.g.:

msbuild -r -p:Configuration=Release the.sln