-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathlayout.ps1
More file actions
79 lines (65 loc) · 2.78 KB
/
Copy pathlayout.ps1
File metadata and controls
79 lines (65 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Inputs
param ([Parameter(Mandatory)] $Configuration, [Parameter(Mandatory)] $Output, $SymbolOutput)
Write-Output "Output: $Output"
# Directories
$THISDIR = $PSScriptRoot
$ROOT = (Get-Item $THISDIR).Parent.Parent.Parent.FullName
$SRC = "$ROOT\src"
$GCM_SRC = "$SRC\shared\Git-Credential-Manager"
# Perform pre-execution checks
$PAYLOAD = "$Output"
if ($SymbolOutput)
{
$SYMBOLS = "$SymbolOutput"
}
else
{
$SYMBOLS = "$PAYLOAD.sym"
}
# Clean up any old payload and symbols directories
if (Test-Path -Path $PAYLOAD)
{
Write-Output "Cleaning old payload directory '$PAYLOAD'..."
Remove-Item -Recurse "$PAYLOAD" -Force
}
if (Test-Path -Path $SYMBOLS)
{
Write-Output "Cleaning old symbols directory '$SYMBOLS'..."
Remove-Item -Recurse "$SYMBOLS" -Force
}
# Ensure payload and symbol directories exist
mkdir -p "$PAYLOAD","$SYMBOLS" | Out-Null
# Publish core application executables
Write-Output "Publishing core application..."
dotnet publish "$GCM_SRC" `
--framework net472 `
--configuration "$Configuration" `
--runtime win-x86 `
--output "$PAYLOAD"
# Delete libraries that are not needed for Windows but find their way
# into the publish output.
Remove-Item -Path "$PAYLOAD/*.dylib" -Force -ErrorAction Ignore
# Delete extraneous files that get included for other architectures
# We only care about x86 as the core GCM executable is only targeting x86
Remove-Item -Path "$PAYLOAD/arm/" -Recurse -Force -ErrorAction Ignore
Remove-Item -Path "$PAYLOAD/arm64/" -Recurse -Force -ErrorAction Ignore
Remove-Item -Path "$PAYLOAD/x64/" -Recurse -Force -ErrorAction Ignore
Remove-Item -Path "$PAYLOAD/musl-x64/" -Recurse -Force -ErrorAction Ignore
Remove-Item -Path "$PAYLOAD/runtimes/win-arm64/" -Recurse -Force -ErrorAction Ignore
Remove-Item -Path "$PAYLOAD/runtimes/win-x64/" -Recurse -Force -ErrorAction Ignore
# The Avalonia and MSAL binaries in these directories are already included in
# the $PAYLOAD directory directly, so we can delete these extra copies.
Remove-Item -Path "$PAYLOAD/x86/libSkiaSharp.dll" -Recurse -Force -ErrorAction Ignore
Remove-Item -Path "$PAYLOAD/x86/libHarfBuzzSharp.dll" -Recurse -Force -ErrorAction Ignore
Remove-Item -Path "$PAYLOAD/runtimes/win-x86/native/msalruntime_x86.dll" -Recurse -Force -ErrorAction Ignore
# Delete localized resource assemblies - we don't localize the core GCM assembly anyway
Get-ChildItem "$PAYLOAD" -Recurse -Include "*.resources.dll" | Remove-Item -Force -ErrorAction Ignore
# Delete any empty directories
Get-ChildItem "$PAYLOAD" -Recurse -Directory `
| Sort-Object -Property FullName -Descending `
| Where-Object { ! (Get-ChildItem $_.FullName -File -Recurse).Count } `
| Remove-Item -Force
# Collect symbols
Write-Output "Collecting managed symbols..."
Move-Item -Path "$PAYLOAD/*.pdb" -Destination "$SYMBOLS"
Write-Output "Layout complete."