Skip to content

Commit

Permalink
Added force parameter to change_toolset.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
KindDragon committed Nov 11, 2015
1 parent 37e977f commit d1c9f27
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions change_toolset.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
Param(
[Parameter(Mandatory=$True,Position=1)]
[string]$toolset
[string]$toolset,
[switch]$force
)

$files = Get-ChildItem -path . -filter *.vcxproj -recurse
foreach ($file in $files) {
if (($file.basename -eq "vld") -or ($file.basename -eq "format"))
if (!$force.IsPresent -and (($file.basename -eq "vld") -or ($file.basename -eq "format")))
{
"Skip $($file.name)"
continue
Expand All @@ -24,3 +25,21 @@ foreach ($file in $files) {
"Toolset not set for $($file.name)"
}
}

$commonProps = ".\src\tests\Common.props"
if ($force.IsPresent -and (Test-Path $commonProps))
{
$content = gc $commonProps
$regex = [regex]"<VldToolset>(v[\d\w_]+)<\/VldToolset>"
$oldtoolset = $regex.matches($content)
if ($oldtoolset.groups.count -ge 1)
{
" Common.props ($($oldtoolset.groups[1].value) - $toolset)"
$content = $content -replace "<VldToolset>(v[\d\w_]+)<\/VldToolset>","<VldToolset>$toolset</VldToolset>"
$content | sc $commonProps
}
else
{
"Toolset not set for $commonProps"
}
}

0 comments on commit d1c9f27

Please sign in to comment.