简体   繁体   English

如何使用 Powershell 强制 Nuget 还原?

[英]How to force Nuget Restore using Powershell?

I'd like to force NuGet to restore my NuGet packages.我想强制 NuGet 恢复我的 NuGet 包。 Going to my solutions directory and type NuGet restore , even with the latest downloaded NuGet.exe doesn't work.转到我的解决方案目录并键入NuGet restore ,即使使用最新下载的NuGet.exe也不起作用。

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).正如这里所解释的,我可以在 Powershell 提示符下使用Update-Package命令执行此操作(因为我不喜欢使用我的 Visual Studio 环境)。

However, my Powershell seems not to understand Update-Package , although I have a +5 version:但是,我的 Powershell 似乎不理解Update-Package ,虽然我有一个 +5 版本:

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?为了在我的 Powershell 中成功启动Update-Package ,我该怎么做?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Artifactory通过PowerShell的身份验证还原nuget软件包 - Artifactory restore nuget packages with authentication from powershell 在 PowerShell 脚本中,如何还原包以解决错误:此项目引用此计算机上缺少的 NuGet 包 - In PowerShell script, how can I restore packages to resolve error: This project references NuGet package(s) that are missing on this computer 如何使用Powershell强制复制文件 - How to force the copy of a file using powershell 如何使用PowerShell将许可证文件添加为自定义NuGet包的一部分 - How to add license files as part of custom NuGet package using PowerShell 如何使用 PowerShell 从 NuGet package 文件的名称中提取版本? - How to extract the version from the name of a NuGet package file using PowerShell? 如何使用 PowerShell 脚本还原 Azure SQL Server 数据库上的架构? - How to restore schema on the Azure SQL Server Databases using PowerShell script? 使用Powershell将Nuget软件包复制文件到本地 - Nuget package copy file to local using powershell Nuget包使用PowerShell进行版本差异分析 - Nuget Packages Version difference analysis using powershell 在 ADO 中使用 PowerShell 任务中的 NuGet - Using NuGet from a PowerShell task in ADO 如何强制 systeminfo 输出为英文以使用 Powershell 对其进行解析? - How to force systeminfo output to english to parse it using Powershell?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM