# This script converts Visual Studio 2022 and 2026 upgraded VS2008 projects to produce # VS2022 or VS2026 projects that will build executables that will link against Visual # Studio 2017 libraries which are stable in the windows_build repo. # #$SDK = $env:WindowsSDKVersion param( [string]$Solution ) $changedProjects = 0 $changedSolution = 0 $SDK = "10.0.26100.0\" $SDK = $SDK.Replace("\","") $solutionFile = $Solution $solutionPath = Split-Path -Path $solutionFile -Parent if (-not $solutionPath.Contains('\')) { $solutionPath = "." } if (-not (Test-Path -Path $solutionFile -PathType Any)) {if (-not (Get-Item -Path $solutionFile -ErrorAction Ignore)) {Write-Host "No such file: $solutionFile"; }} $solution = Get-Content -Path $solutionFile -Raw $startingSolution = $Solution if ($solution -match 'Project\("{([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})}"\) = "BuildROMs", "BuildROMs.[a-z]*", "{([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})}"') { $BuildROMsGUID = $($Matches[2]) } $Projects = [Regex]::Matches($solution, '(?sm)}"\) = "(?.*?)", "(?.*?)"') if ($solution.Contains(".vcproj")) { Write-Host "Attempting to fix Solution file which wasn't completely migrated:" Write-Host $solutionFile } $dependencyPattern = "(?sm)\s\sProjectSection\(ProjectDependencies\) \= postProject.*?({.*?}).*?EndProjectSection" $solution = $solution -replace $dependencyPattern, "" $solution = $solution -replace ".vcproj", ".vcxproj" if (-not $solution.Contains("GlobalSection(ExtensibilityGlobals)")) { $solution = $solution.Replace( "EndGlobal ", " GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {$(New-Guid)} EndGlobalSection EndGlobal ") $solution = $solution.Replace("Format Version 10.00", "Format Version 12.00") $solution = $solution.Replace("Visual C++ Express 2008", "Visual Studio Version 17 VisualStudioVersion = 17.14.36705.20 d17.14 MinimumVisualStudioVersion = 10.0.40219.1") } ForEach ($Project in $Projects) { $projFile = $solutionPath + "\" + $($Project.Groups['file'].Value).Replace(".vcproj", ".vcxproj") if (-not (Test-Path -Path $ProjFile -PathType Any)) {if (-not (Get-Item -Path $ProjFile -ErrorAction Ignore)) {Write-Host "No such file: $ProjFile"; continue; }} $projString = Get-Content -Path $projFile -Raw $startingProjString = $projString if ($projString.Contains("")) {Write-Host "$projFile - already converted"; continue; } $projString = $projString.Replace( "Win32Proj ", "Win32Proj $SDK ") $projString = $projString.Replace("v143","v141") $projString = $projString.Replace("v144","v141") $projString = $projString.Replace("v145","v141") $projString = $projString.Replace( ' Label="LocalAppDataPlatform" /> ',' Label="LocalAppDataPlatform" /> ') if (-not $projString.Contains($BuildROMsGUID)) { $ProjString = $ProjString.Replace( ' ', (' {' + $BuildROMsGUID.ToLower() + '} false ')) } if (-not ($projString -ceq $startingProjString)) { $projString | Out-File -Force -FilePath "$projFile" -Encoding utf8 $changedProjects = $changedProjects + 1 } } if (-not ($solution -ceq $startingSolution)) { $solution | Out-File -Force -FilePath "$solutionFile" -Encoding utf8 $changedSolution = 1 } Write-Host "Projects Changed: $changedProjects Solution Changed: $changedSolution"