问题
I am trying to update a single package in a csproj with multiple dependencies. That is, the packages.config file looks like this:
<packages>
<package id="PackageA" version="1.2.1" targetFramework="net40" />
<package id="PackageB" version="2.3.4" targetFramework="net40" />
<package id="PackageC" version="1.0.0" targetFramework="net40" />
</packages>
I'd like to update PackageA without updating the others. I see that Update-Package in the Visual Studio package manager has this capability, but this needs to run on a TFS build machine.
Is there a way to do this from the command line? The anticipated workflow is the build machine running
- Nuget.exe restore
- Nuget.exe update (on each csproj file)
But the update command does not allow us to specify which package to update on. I know there is an allowedVersions tag for the packages, but that is would require us to change the packages.config file when creating different branches that require different components to update or not, whereas a package-specific, csproj-specific command-line would allow us to associate the dependencies to update with each TFS branch via its build definitions.
回答1:
nuget.exe update
has an -Id argument that specifies the project. So, for instance,
nuget.exe update X.csproj -Id PackageA
来源:https://stackoverflow.com/questions/27993773/how-do-i-update-a-single-nuget-package-in-a-project-from-the-command-line