Created
May 15, 2013 10:15
-
-
Save dotnetdude/5582964 to your computer and use it in GitHub Desktop.
Loop through all VB CS project files (Visual studio 2012) in a folder / Sub folder, Checkout the File, Change the Reference Location and Save the File.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ######## Loop through all VB CS VS project files ((Visual studio 2012) in a folder and Sub folder, Checkout the File, Change the Reference Location and Save the File. | |
| ######## How to use | |
| ######## 1) cd "folder path" | |
| ######## 2) .\bulk_reference_update.ps1 ..\..\..\Deploy\packages ..\..\..\Packages | |
| ######## | |
| $findpath = [regex]::escape($args[0]); | |
| $replacepath = $args[1]; | |
| ### -- Change TF.exe location if it is different in your machine. | |
| $tf = "c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\TF.exe" | |
| Function CheckoutProjectFile($pf) | |
| { | |
| $arg = "edit " + $pf + " /noprompt" | |
| $ec = (Start-Process -FilePath $tf -ArgumentList $arg -Wait -Passthru -WindowStyle Hidden).ExitCode | |
| return $ec | |
| } | |
| dir -Recurse *.*proj | ` | |
| ForEach-Object { | |
| $xml = [xml](Get-Content $_.FullName); | |
| $projectFileName = $_.FullName | |
| $fileChanged = 0; | |
| ForEach-Object {$xml} | ` | |
| ForEach-Object { $_.Project.ItemGroup.Reference } | ` | |
| Where-Object { (($_.Include -ne $null) -and ` | |
| ($_.HintPath -match $findpath )) } | ` | |
| ForEach-Object { | |
| $_.HintPath = $_.HintPath -replace $findpath, $replacepath; | |
| Write-Host Changed the reference to $_.HintPath in $projectFileName | |
| $fileChanged = 1; | |
| } | |
| if ($fileChanged -eq 1) | |
| { | |
| if (CheckoutProjectFile $projectFileName -eq 1) | |
| { Write-Host Error Checking out Project file $projectFileName -foregroundcolor "red" } | |
| else | |
| { $xml.save($projectFileName); } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment