How to specify private nuget package source in msbuild 15.0 command line?

MS Build reads NuGet.Config files from the solution root. You can add a new Nuget.config file and specify the external repositories inside that.

nuget.config reference


How to specify private nuget package source in msbuild 15.0 command line?

If you want to restore the nuget package only from the specify private nuget package source, you could use the property RestoreSources to specify private source:

msbuild /t:restore /p:RestoreSources=xxx /tv:15.0 /t:Rebuild /p:Configuration=Release

Check the restore target for some more details.


you can use /p:RestoreAdditionalProjectSources=… to specify other sources.

Also, use /restore (MSBuild 15.3+) instead of specifying Restore together with other targets so all changed files generated by NuGet are properly reloaded.