Enhance CI workflow to install additional ATL and MFC components for … #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: [pull_request, push, workflow_dispatch] | |
| permissions: {} | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: ${{ github.head_ref != '' }} | |
| jobs: | |
| ci: | |
| name: Build | |
| runs-on: windows-latest | |
| env: | |
| FBSDK_VERSION: 2025-03-07 | |
| SOL_FILE: foo_opensubsonic.sln | |
| MSBUILD_CMD_X86: /maxcpucount /property:RestorePackagesConfig=true,Configuration=Release,Platform=Win32,UseOfAtl=Static /target:restore,build | |
| MSBUILD_CMD_X64: /maxcpucount /property:RestorePackagesConfig=true,Configuration=Release,Platform=x64,UseOfAtl=Static /target:restore,build | |
| MSBUILD_CMD_ARM64EC: /maxcpucount /property:RestorePackagesConfig=true,Configuration=Release,Platform=ARM64EC,UseOfAtl=Static /target:restore,build | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6.0.2 | |
| - name: Download and extract foobar2000 SDK | |
| run: | | |
| (New-Object System.Net.WebClient).DownloadFile("https://www.foobar2000.org/files/SDK-${{ env.FBSDK_VERSION }}.7z", "${{ runner.temp }}\fbsdk.7z") | |
| 7z x "${{ runner.temp }}\fbsdk.7z" -o"lib\foobar2000_sdk" > nul | |
| - name: Download WTL and nlohmann/json | |
| run: | | |
| git clone https://git.code.sf.net/p/wtl/git lib\wtl | |
| New-Item -ItemType Directory -Force -Path "lib\nlohmann" | |
| (New-Object System.Net.WebClient).DownloadFile("https://github.com/nlohmann/json/releases/download/v3.12.0/json.hpp", "lib\nlohmann\json.hpp") | |
| (New-Object System.Net.WebClient).DownloadFile("https://github.com/nlohmann/json/releases/download/v3.12.0/json_fwd.hpp", "lib\nlohmann\json_fwd.hpp") | |
| dir lib | |
| - name: Patch SDK | |
| shell: pwsh | |
| run: | | |
| $projectPatches = @{ | |
| "lib\foobar2000_sdk\libPPUI\libPPUI.vcxproj" = "../..;..;..\..\wtl\Include;%(AdditionalIncludeDirectories)" | |
| "lib\foobar2000_sdk\foobar2000\helpers\foobar2000_sdk_helpers.vcxproj" = "..;..\..;..\..\..\wtl\Include;%(AdditionalIncludeDirectories)" | |
| } | |
| foreach ($project in $projectPatches.GetEnumerator()) { | |
| $filePath = Resolve-Path $project.Key | |
| [xml]$x = Get-Content $filePath | |
| $ns = New-Object System.Xml.XmlNamespaceManager($x.NameTable) | |
| $ns.AddNamespace("msb", "http://schemas.microsoft.com/developer/msbuild/2003") | |
| $msbuildNs = $ns.LookupNamespace("msb") | |
| $x.SelectNodes("//msb:ClCompile/msb:AdditionalIncludeDirectories", $ns) | ForEach-Object { | |
| $_.InnerText = $project.Value | |
| } | |
| $x.SelectNodes("//msb:PropertyGroup[@Label='Configuration']", $ns) | ForEach-Object { | |
| $useOfAtl = $_.SelectSingleNode("msb:UseOfAtl", $ns) | |
| if ($null -eq $useOfAtl) { | |
| $useOfAtl = $x.CreateElement("UseOfAtl", $msbuildNs) | |
| [void]$_.AppendChild($useOfAtl) | |
| } | |
| $useOfAtl.InnerText = "Static" | |
| } | |
| $x.Save($filePath) | |
| } | |
| - name: Install ATL components | |
| shell: pwsh | |
| run: | | |
| $vswhere = Join-Path ${env:ProgramFiles(x86)} "Microsoft Visual Studio\Installer\vswhere.exe" | |
| $vsInstaller = Join-Path ${env:ProgramFiles(x86)} "Microsoft Visual Studio\Installer\vs_installer.exe" | |
| $installPath = & $vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath | |
| if (-not $installPath) { | |
| throw "Visual Studio installation path not found" | |
| } | |
| & $vsInstaller modify ` | |
| --installPath "$installPath" ` | |
| --add Microsoft.VisualStudio.Component.VC.ATL ` | |
| --add Microsoft.VisualStudio.Component.VC.ATLMFC ` | |
| --add Microsoft.VisualStudio.Component.VC.ATL.ARM64 ` | |
| --add Microsoft.VisualStudio.Component.VC.MFC.ARM64 ` | |
| --add Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL ` | |
| --add Microsoft.VisualStudio.Component.VC.14.29.16.11.MFC ` | |
| --add Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL.ARM64 ` | |
| --add Microsoft.VisualStudio.Component.VC.14.29.16.11.MFC.ARM64 ` | |
| --quiet --norestart --wait | |
| if ($LASTEXITCODE -ne 0) { | |
| throw "Visual Studio component installation failed with exit code $LASTEXITCODE" | |
| } | |
| $atlHeaders = Get-ChildItem -Path (Join-Path $installPath "VC\Tools\MSVC") -Filter atlbase.h -Recurse -ErrorAction SilentlyContinue | |
| if (-not $atlHeaders) { | |
| throw "ATL headers are still missing after component installation" | |
| } | |
| $atlHeaders | Select-Object -ExpandProperty FullName | |
| - name: Setup devcmd | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| - name: Build x86 | |
| run: | | |
| msbuild ${{ env.SOL_FILE }} ${{ env.MSBUILD_CMD_X86 }} | |
| - name: Build x64 | |
| run: | | |
| msbuild ${{ env.SOL_FILE }} ${{ env.MSBUILD_CMD_X64 }} | |
| - name: Build ARM64EC | |
| run: | | |
| msbuild ${{ env.SOL_FILE }} ${{ env.MSBUILD_CMD_ARM64EC }} | |
| - name: Prepare build artifacts | |
| run: | | |
| copy "Release\foo_opensubsonic.dll" "." | |
| copy "x64\Release\foo_opensubsonic.dll" "x64" | |
| New-Item -ItemType Directory -Force -Path "arm64ec" | |
| copy "ARM64EC\Release\foo_opensubsonic.dll" "arm64ec" | |
| 7z a -tzip -mx9 "foo_opensubsonic.fb2k-component" "foo_opensubsonic.dll" "x64\foo_opensubsonic.dll" "arm64ec\foo_opensubsonic.dll" | |
| $hash = (Get-FileHash -Algorithm SHA256 "foo_opensubsonic.fb2k-component").hash.ToString().toLower() | |
| Write-Output "$hash *foo_opensubsonic.fb2k-component" > "foo_opensubsonic.fb2k-component.sha256" | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v7.0.1 | |
| with: | |
| name: foo_opensubsonic | |
| path: | | |
| foo_opensubsonic.fb2k-component | |
| foo_opensubsonic.fb2k-component.sha256 |