在解决方案中更新所有项目中的nuget包

时间:2021-07-30 14:10:30

I have a .net solution (say A) with multiple projects(say B,C,D). I want to update all nuget packages for all projects in the solution. I know I can update nuget packages using command line but passing in the path to packages.config

我有一个.net解决方案(比如A)有多个项目(比如B,C,D)。我想更新解决方案中所有项目的所有nuget包。我知道我可以使用命令行更新nuget包,但是将路径传递给packages.config

nuget update A/B/packages.config

Is there a way to update packages for all packages.configs inside folder A using command line without having to specify them individually? (I know this can be done from inside visual studio.) Something like

有没有办法使用命令行更新文件夹A中所有packages.configs的包,而无需单独指定它们? (我知道这可以从视觉工作室内完成。)像

nuget update A/*/packages.config

3 个解决方案

#1


25  

As found in NuGet documentation, you can type:

如NuGet文档中所示,您可以键入:

Update-Package

This will :

这会 :

Update all packages in all projects of the current solution to the latest versions.

将当前解决方案的所有项目中的所有包更新到最新版本。

To open the Package Manager Console:

要打开包管理器控制台:

Tools > NuGet Package Manager > Package Manager Console

工具> NuGet包管理器>包管理器控制台

Now, in order to have only one instance of all packages, I have, in my solution folder, a file named nuget.config that contains:

现在,为了只有一个所有包的实例,我在我的解决方案文件夹中有一个名为nuget.config的文件,其中包含:

<configuration>
  <config>
    <add key="repositoryPath" value="..\Path\To\My\Packages" />
  </config>
</configuration>

You might need to reload your solution in order to make it work properly.

您可能需要重新加载解决方案才能使其正常工作。

#2


9  

You have used command line examples, but your question does not state if you require a command line answer. If you do not require command line, you can right-click on your solution in the Solution Explorer, and select Manage NuGet Packages for Solution ... This displays a dialog where you can make your selections. Other than that, you'd need to write a script at this point in time anyway (as far as I know).

您已使用命令行示例,但您的问题并未说明是否需要命令行答案。如果您不需要命令行,可以在解决方案资源管理器中右键单击解决方案,然后选择管理解决方案的NuGet包...这将显示一个对话框,您可以在其中进行选择。除此之外,你还需要在这个时间点写一个脚本(据我所知)。

#3


5  

First you have to restore all packages using nuget restore solution_file.sln then update them to latest version by executing nuget update solution_file.sln.

首先,您必须使用nuget restore solution_file.sln恢复所有包,然后通过执行nuget update solution_file.sln将它们更新到最新版本。

Read more about nuget command line

阅读有关nuget命令行的更多信息

#1


25  

As found in NuGet documentation, you can type:

如NuGet文档中所示,您可以键入:

Update-Package

This will :

这会 :

Update all packages in all projects of the current solution to the latest versions.

将当前解决方案的所有项目中的所有包更新到最新版本。

To open the Package Manager Console:

要打开包管理器控制台:

Tools > NuGet Package Manager > Package Manager Console

工具> NuGet包管理器>包管理器控制台

Now, in order to have only one instance of all packages, I have, in my solution folder, a file named nuget.config that contains:

现在,为了只有一个所有包的实例,我在我的解决方案文件夹中有一个名为nuget.config的文件,其中包含:

<configuration>
  <config>
    <add key="repositoryPath" value="..\Path\To\My\Packages" />
  </config>
</configuration>

You might need to reload your solution in order to make it work properly.

您可能需要重新加载解决方案才能使其正常工作。

#2


9  

You have used command line examples, but your question does not state if you require a command line answer. If you do not require command line, you can right-click on your solution in the Solution Explorer, and select Manage NuGet Packages for Solution ... This displays a dialog where you can make your selections. Other than that, you'd need to write a script at this point in time anyway (as far as I know).

您已使用命令行示例,但您的问题并未说明是否需要命令行答案。如果您不需要命令行,可以在解决方案资源管理器中右键单击解决方案,然后选择管理解决方案的NuGet包...这将显示一个对话框,您可以在其中进行选择。除此之外,你还需要在这个时间点写一个脚本(据我所知)。

#3


5  

First you have to restore all packages using nuget restore solution_file.sln then update them to latest version by executing nuget update solution_file.sln.

首先,您必须使用nuget restore solution_file.sln恢复所有包,然后通过执行nuget update solution_file.sln将它们更新到最新版本。

Read more about nuget command line

阅读有关nuget命令行的更多信息