Skip to content

Commit

Permalink
Add some guesswork code to detect the VCRedistTools folder on the bui…
Browse files Browse the repository at this point in the history
…ld agent
  • Loading branch information
codereader committed Apr 16, 2021
1 parent 0b06e1b commit 3321fef
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Expand Up @@ -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

Expand All @@ -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
Expand Down
30 changes: 25 additions & 5 deletions tools/scripts/compile_release_package.ps1
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3321fef

Please sign in to comment.