Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automate nuget update-package operation on many VS solutions

I've got 10+ Visual Studio solutions that are referencing a nuget package. When I decide to update that package in every solution it's a very long work to open each solution manually, update its package and check-in all changes to TFS. I'd like to "automate" this process with a batch operation that does it on behalf of me.

I've made some experiments with nuget.exe by command line but it doesn't care about TFS read-only files: it overwrites the content of my files without checking-out them so this way seems not the best way to do it.

Any other suggestion to achieve the aim?

like image 492
Luca Avatar asked Dec 05 '25 20:12

Luca


1 Answers

You can use nuget update command to do this. VS/TFS can detect the changes even thought you are running the command outside from VS. And usually, only "packages.config" file will be updated during the nuget package update.

Update: Following is a simple code to find the solution files under the given path and update the nuget packages for the solution and then check in the pending changes via TFS PowerShell CommandLets (You need to install "TFS Power Tool" to use this commandlet). You can update according to your scenario.

param([String]$dirpath)

add-pssnapin Microsoft.TeamFoundation.PowerShell;

Get-ChildItem -Path $dirpath -Filter *.sln -Recurse | ForEach-Object { & nuget update $_.FullName 2>1;  cd $_.Directory; get-tfspendingchange; new-tfschangeset}

Save the code as a powershell script and run it from Windows PowerShell with argument "-dirpath yoursolutionpath". It will run as following: enter image description here

like image 93
Eddie Chen - MSFT Avatar answered Dec 08 '25 15:12

Eddie Chen - MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!