|
1 | 1 | # Inputs |
2 | | -param ([Parameter(Mandatory)] $Configuration, [Parameter(Mandatory)] $Output, $SymbolOutput) |
| 2 | +param ([Parameter(Mandatory)] $Configuration, [Parameter(Mandatory)] $Output, $RuntimeIdentifier, $SymbolOutput) |
3 | 3 |
|
4 | 4 | Write-Output "Output: $Output" |
5 | 5 |
|
| 6 | +# Determine a runtime if one was not provided |
| 7 | +if (-not $RuntimeIdentifier) { |
| 8 | + $arch = $env:PROCESSOR_ARCHITECTURE |
| 9 | + switch ($arch) { |
| 10 | + "AMD64" { $RuntimeIdentifier = "win-x64" } |
| 11 | + "x86" { $RuntimeIdentifier = "win-x86" } |
| 12 | + "ARM64" { $RuntimeIdentifier = "win-arm64" } |
| 13 | + default { |
| 14 | + Write-Host "Unknown architecture: $arch" |
| 15 | + exit 1 |
| 16 | + } |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +Write-Output "Building for runtime '$RuntimeIdentifier'" |
| 21 | + |
| 22 | +if ($RuntimeIdentifier -ne 'win-x86' -and $RuntimeIdentifier -ne 'win-x64' -and $RuntimeIdentifier -ne 'win-arm64') { |
| 23 | + Write-Host "Unsupported RuntimeIdentifier: $RuntimeIdentifier" |
| 24 | + exit 1 |
| 25 | +} |
| 26 | + |
6 | 27 | # Directories |
7 | 28 | $THISDIR = $PSScriptRoot |
8 | 29 | $ROOT = (Get-Item $THISDIR).Parent.Parent.Parent.FullName |
@@ -41,27 +62,55 @@ Write-Output "Publishing core application..." |
41 | 62 | dotnet publish "$GCM_SRC" ` |
42 | 63 | --framework net472 ` |
43 | 64 | --configuration "$Configuration" ` |
44 | | - --runtime win-x86 ` |
| 65 | + --runtime $RuntimeIdentifier ` |
45 | 66 | --output "$PAYLOAD" |
46 | 67 |
|
47 | 68 | # Delete libraries that are not needed for Windows but find their way |
48 | 69 | # into the publish output. |
49 | 70 | Remove-Item -Path "$PAYLOAD/*.dylib" -Force -ErrorAction Ignore |
50 | 71 |
|
51 | | -# Delete extraneous files that get included for other architectures |
52 | | -# We only care about x86 as the core GCM executable is only targeting x86 |
53 | | -Remove-Item -Path "$PAYLOAD/arm/" -Recurse -Force -ErrorAction Ignore |
54 | | -Remove-Item -Path "$PAYLOAD/arm64/" -Recurse -Force -ErrorAction Ignore |
55 | | -Remove-Item -Path "$PAYLOAD/x64/" -Recurse -Force -ErrorAction Ignore |
| 72 | +# Delete extraneous files that get included for other runtimes |
56 | 73 | Remove-Item -Path "$PAYLOAD/musl-x64/" -Recurse -Force -ErrorAction Ignore |
57 | | -Remove-Item -Path "$PAYLOAD/runtimes/win-arm64/" -Recurse -Force -ErrorAction Ignore |
58 | | -Remove-Item -Path "$PAYLOAD/runtimes/win-x64/" -Recurse -Force -ErrorAction Ignore |
59 | | - |
60 | | -# The Avalonia and MSAL binaries in these directories are already included in |
61 | | -# the $PAYLOAD directory directly, so we can delete these extra copies. |
62 | | -Remove-Item -Path "$PAYLOAD/x86/libSkiaSharp.dll" -Recurse -Force -ErrorAction Ignore |
63 | | -Remove-Item -Path "$PAYLOAD/x86/libHarfBuzzSharp.dll" -Recurse -Force -ErrorAction Ignore |
64 | | -Remove-Item -Path "$PAYLOAD/runtimes/win-x86/native/msalruntime_x86.dll" -Recurse -Force -ErrorAction Ignore |
| 74 | + |
| 75 | +switch ($RuntimeIdentifier) { |
| 76 | + "win-x86" { |
| 77 | + Remove-Item -Path "$PAYLOAD/arm/" -Recurse -Force -ErrorAction Ignore |
| 78 | + Remove-Item -Path "$PAYLOAD/arm64/" -Recurse -Force -ErrorAction Ignore |
| 79 | + Remove-Item -Path "$PAYLOAD/x64/" -Recurse -Force -ErrorAction Ignore |
| 80 | + Remove-Item -Path "$PAYLOAD/runtimes/win-arm64/" -Recurse -Force -ErrorAction Ignore |
| 81 | + Remove-Item -Path "$PAYLOAD/runtimes/win-x64/" -Recurse -Force -ErrorAction Ignore |
| 82 | + # The Avalonia and MSAL binaries are already included in the $PAYLOAD directory directly |
| 83 | + Remove-Item -Path "$PAYLOAD/x86/libSkiaSharp.dll" -Force -ErrorAction Ignore |
| 84 | + Remove-Item -Path "$PAYLOAD/x86/libHarfBuzzSharp.dll" -Force -ErrorAction Ignore |
| 85 | + Remove-Item -Path "$PAYLOAD/runtimes/win-x86/native/msalruntime_x86.dll" -Force -ErrorAction Ignore |
| 86 | + } |
| 87 | + "win-x64" { |
| 88 | + Remove-Item -Path "$PAYLOAD/arm/" -Recurse -Force -ErrorAction Ignore |
| 89 | + Remove-Item -Path "$PAYLOAD/arm64/" -Recurse -Force -ErrorAction Ignore |
| 90 | + Remove-Item -Path "$PAYLOAD/x86/" -Recurse -Force -ErrorAction Ignore |
| 91 | + Remove-Item -Path "$PAYLOAD/runtimes/win-arm64/" -Recurse -Force -ErrorAction Ignore |
| 92 | + Remove-Item -Path "$PAYLOAD/runtimes/win-x86/" -Recurse -Force -ErrorAction Ignore |
| 93 | + # The Avalonia and MSAL binaries are already included in the $PAYLOAD directory directly |
| 94 | + Remove-Item -Path "$PAYLOAD/x64/libSkiaSharp.dll" -Force -ErrorAction Ignore |
| 95 | + Remove-Item -Path "$PAYLOAD/x64/libHarfBuzzSharp.dll" -Force -ErrorAction Ignore |
| 96 | + Remove-Item -Path "$PAYLOAD/x64/libSkiaSharp.so" -Force -ErrorAction Ignore |
| 97 | + Remove-Item -Path "$PAYLOAD/x64/libHarfBuzzSharp.so" -Force -ErrorAction Ignore |
| 98 | + Remove-Item -Path "$PAYLOAD/runtimes/win-x64/native/msalruntime.dll" -Force -ErrorAction Ignore |
| 99 | + } |
| 100 | + "win-arm64" { |
| 101 | + Remove-Item -Path "$PAYLOAD/arm/" -Recurse -Force -ErrorAction Ignore |
| 102 | + Remove-Item -Path "$PAYLOAD/x86/" -Recurse -Force -ErrorAction Ignore |
| 103 | + Remove-Item -Path "$PAYLOAD/x64/" -Recurse -Force -ErrorAction Ignore |
| 104 | + Remove-Item -Path "$PAYLOAD/runtimes/win-x86/" -Recurse -Force -ErrorAction Ignore |
| 105 | + Remove-Item -Path "$PAYLOAD/runtimes/win-x64/" -Recurse -Force -ErrorAction Ignore |
| 106 | + # The Avalonia and MSAL binaries are already included in the $PAYLOAD directory directly |
| 107 | + Remove-Item -Path "$PAYLOAD/arm64/libSkiaSharp.dll" -Force -ErrorAction Ignore |
| 108 | + Remove-Item -Path "$PAYLOAD/arm64/libHarfBuzzSharp.dll" -Force -ErrorAction Ignore |
| 109 | + Remove-Item -Path "$PAYLOAD/arm64/libSkiaSharp.so" -Force -ErrorAction Ignore |
| 110 | + Remove-Item -Path "$PAYLOAD/arm64/libHarfBuzzSharp.so" -Force -ErrorAction Ignore |
| 111 | + Remove-Item -Path "$PAYLOAD/runtimes/win-arm64/native/msalruntime_arm64.dll" -Force -ErrorAction Ignore |
| 112 | + } |
| 113 | +} |
65 | 114 |
|
66 | 115 | # Delete localized resource assemblies - we don't localize the core GCM assembly anyway |
67 | 116 | Get-ChildItem "$PAYLOAD" -Recurse -Include "*.resources.dll" | Remove-Item -Force -ErrorAction Ignore |
|
0 commit comments