Skip to content

Instantly share code, notes, and snippets.

@deurell
Last active August 29, 2015 14:20
Show Gist options
  • Save deurell/50d9185662110daab572 to your computer and use it in GitHub Desktop.
Save deurell/50d9185662110daab572 to your computer and use it in GitHub Desktop.
project file conversion utility
# project file conversion utility
param (
[string]$folderPath = $(throw "-folderPath is required.")
)
$allProjectFiles = get-childitem -path $folderPath -Filter *.vcxproj -Recurse
foreach ($projectFile in $allProjectFiles){
$projectFileContent = get-content $projectFile.FullName
$projectFileContent |
foreach-object {$_ -creplace [regex]::Escape("Debug|ARM"), "Debug|Win32"} |
foreach-object {$_ -creplace [regex]::Escape("Release|ARM"), "Release|Win32"} |
foreach-object {$_ -creplace [regex]::Escape("MinSizeRel|ARM"), "MinSizeRel|Win32"} |
foreach-object {$_ -creplace [regex]::Escape("RelWithDebInfo|ARM"), "RelWithDebInfo|Win32"} |
foreach-object {$_ -creplace "<Platform>ARM</Platform>", "<Platform>Win32</Platform>"} |
foreach-object {$_ -creplace "<PlatformToolset>v120_wp81</PlatformToolset>", "<PlatformToolset>v140</PlatformToolset>"} |
foreach-object {$_ -creplace "/machine:ARM", "/machine:Win32"} |
foreach-object {$_ -creplace "<ApplicationType>Windows Phone</ApplicationType>", "<ApplicationType>Windows Store</ApplicationType>"} |
foreach-object {$_ -creplace "<ApplicationTypeRevision>8.1</ApplicationTypeRevision>", "<ApplicationTypeRevision>8.2</ApplicationTypeRevision>"} |
foreach-object {$_ -creplace "<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>", "<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>"} | out-file $projectFile.FullName -encoding UTF8
write-host 'converted' $projectFile
}
@deurell
Copy link
Author

deurell commented May 7, 2015

Needs to escape regexp meta chars with this beautiful syntax.

@deurell
Copy link
Author

deurell commented May 7, 2015

Forcing UTF8. Default writes UTF16 and Visual Studio doesn't like that for project files.

@deurell
Copy link
Author

deurell commented May 7, 2015

Added converters for /machine:Win32 and PlatformToolset

@deurell
Copy link
Author

deurell commented May 7, 2015

usage:
win10-convert.ps1 -folderPath c:\dev\ff-sample\mobile\projects\testrun4\

@johanlindfors
Copy link

Varför inte bara:
foreach-object {$_ -creplace [regex]::Escape("ARM"), "Win32"}
istället för alla olika fall?

@deurell
Copy link
Author

deurell commented May 7, 2015

Jag fick en bugg när jag gjorde det förut. Tror dock att det berodde på att jag inte escapade regexp korrekt. Troligtvis bara att byta och få lite snyggare kod.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment