简体   繁体   中英

How to force Nuget Restore using Powershell?

I'd like to force NuGet to restore my NuGet packages. Going to my solutions directory and type NuGet restore , even with the latest downloaded NuGet.exe doesn't work.

As explained here , I can do this in a Powershell prompt, using the Update-Package command (as I prefer not to use my Visual Studio environment).

However, my Powershell seems not to understand Update-Package , although I have a +5 version:

PowerShell Prompt> Get-Host | Select-Object Version

Version
-------
5.1.19041.1023


PowerShell Prompt> Update-Package -reinstall
Update-Package : The term 'Update-Package' is not recognized as the name of a cmdlet, function,
script file, or operable program.
Check the spelling of the name, or if a path was included, verify that 
the path is correct and try again.
At line:1 char:1
+ Update-Package -reinstall
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Update-Package:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

What can I do in order to launch Update-Package successfully in my Powershell?

Thanks in advance

I don't use Update-Package, but the following:

 & "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" /t:restore  C:\code\projectdirectory

Standard powershell doesn't ship have NuGet restore functionality.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM