Updating nuget packages in all projects in a solution

前端 未结 3 1382
忘掉有多难
忘掉有多难 2021-02-06 22:43

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

相关标签:
3条回答
  • 2021-02-06 23:27

    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).

    0 讨论(0)
  • 2021-02-06 23:42

    As found in NuGet documentation, you can type:

    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

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

    <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.

    0 讨论(0)
  • 2021-02-06 23:49

    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.

    Read more about nuget command line

    Updated link to Nuget command line documentation

    Nuget Package Manager Console documentation (Visual Studio for Windows)

    Edit: Previous link is dead. Added working equivalent and bonus Package Manager Console link.

    0 讨论(0)
提交回复
热议问题