diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b3f152feb3..8d191e842b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -48,7 +48,7 @@ jobs: shell: cmd - name: Generate Portable Package - run: powershell -ExecutionPolicy ByPass .\compile_release_package.ps1 -Platform x64 -SkipBuild -GenerateSetupPackage:$false -GeneratePortablePackage:$true -OutputFolder ..\..\PortablePackage\ + run: powershell -ExecutionPolicy ByPass .\compile_release_package.ps1 -Platform x64 -SkipBuild -GenerateSetupPackage:$false -GeneratePortablePackage:$false -OutputFolder ..\..\PortablePackage\ shell: cmd working-directory: .\tools\scripts @@ -57,15 +57,15 @@ jobs: with: name: darkradiant-portable-package-x64 path: | - PortablePackage/**/* - !PortablePackage/**/*.pdb + tools/scripts/DarkRadiant_install.x64/**/* + !tools/scripts/DarkRadiant_install.x64/**/*.pdb - name: Upload Portable Package PDBs uses: actions/upload-artifact@v2 with: name: darkradiant-pdb-files-x64 path: | - PortablePackage/**/*.pdb + tools/scripts/DarkRadiant_install.x64/**/*.pdb - name: Upload Test Results uses: actions/upload-artifact@v2 diff --git a/tools/scripts/compile_release_package.ps1 b/tools/scripts/compile_release_package.ps1 index 302a43bdd0..f3bb15a524 100644 --- a/tools/scripts/compile_release_package.ps1 +++ b/tools/scripts/compile_release_package.ps1 @@ -53,7 +53,7 @@ if ($GenerateSetupPackage -and $null -eq (Get-Command "compil32" -ErrorAction Si return } -if (-not $SkipBuild -and ($null -eq (Get-Command "msbuild" -ErrorAction SilentlyContinue) -or $null -eq $env:VCToolsRedistDir)) +if (-not $SkipBuild -and ($null -eq (Get-Command "msbuild" -ErrorAction SilentlyContinue))) { Write-Host -ForegroundColor Red "For this script to run, please make sure that you've opened the corresponding studio developer command prompt." return @@ -87,19 +87,39 @@ foreach ($line in $content) } } +# Check the location of the VC redist folder +$vcRedistFolder = $env:VCToolsRedistDir + +if ($null -eq $vcRedistFolder) +{ + Write-Host "Trying to guess the VCRedistTools folder location..." + + $candidate = Get-ChildItem -Path "C:\Program Files (x86)\Microsoft Visual Studio\" -Recurse -Filter "Redist" | ? { (Get-ChildItem -Path $_.FullName -Filter "MSVC") } + + if ($null -ne $candidate) + { + $candidate = Join-Path $candidate.FullName "MSVC" + + $candidate = Get-ChildItem -Recurse -Path $candidate -Filter $target -Depth 1 | ? { (Get-ChildItem -Path $_.FullName -Filter "Microsoft.VC142.CRT") } | Select -First 1 + + $vcRedistFolder = $candidate.Parent.FullName + Write-Host "Guessed this path: $vcRedistFolder" + } +} + if ($target -eq "x86") { $platform = "Win32" $issFile = "..\innosetup\darkradiant.iss" $portablePath = "DarkRadiant_install" - $redistSource = Join-Path $env:VCToolsRedistDir "x86\Microsoft.VC142.CRT" + $redistSource = Join-Path $vcRedistFolder "x86\Microsoft.VC142.CRT" } else { $platform = "x64" $issFile = "..\innosetup\darkradiant.x64.iss" $portablePath = "DarkRadiant_install.x64" - $redistSource = Join-Path $env:VCToolsRedistDir "x64\Microsoft.VC142.CRT" + $redistSource = Join-Path $vcRedistFolder "x64\Microsoft.VC142.CRT" } if (-not $SkipBuild) @@ -151,8 +171,8 @@ if ($GenerateSetupPackage) Write-Host ("Writing version {0} to InnoSetup file" -f $foundVersionString) $issContent = Get-Content $issFile $issContent = $issContent -replace '#define DarkRadiantVersion "(.+)"', ('#define DarkRadiantVersion "{0}"' -f $foundVersionString) - Write-Host ("Writing redist folder {0} to InnoSetup file" -f $env:VCToolsRedistDir) - $issContent = $issContent -replace '#define VCRedistDir "(.+)"', ('#define VCRedistDir "{0}"' -f $env:VCToolsRedistDir) + Write-Host ("Writing redist folder {0} to InnoSetup file" -f $vcRedistFolder) + $issContent = $issContent -replace '#define VCRedistDir "(.+)"', ('#define VCRedistDir "{0}"' -f $vcRedistFolder) Set-Content -Path $issFile -Value $issContent # Compile the installer package