Skip to content

Commit dfa3b49

Browse files
committed
windows/layout.ps1: clean up layout script
Clean up the Windows payload layout script to avoid errors when removing files that don't exist. Also make the script parameters use normal casing rules. Signed-off-by: Matthew John Cheetham <[email protected]>
1 parent b62021f commit dfa3b49

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

src/windows/Installer.Windows/layout.ps1

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
# Inputs
2-
param ([Parameter(Mandatory)] $CONFIGURATION, [Parameter(Mandatory)] $OUTPUT, $SYMBOLOUTPUT)
2+
param ([Parameter(Mandatory)] $Configuration, [Parameter(Mandatory)] $Output, $SymbolOutput)
33

4-
Write-Output "Output: $OUTPUT"
4+
Write-Output "Output: $Output"
55

66
# Directories
7-
$THISDIR = $pwd.path
8-
$ROOT = (Get-Item $THISDIR).parent.parent.parent.FullName
9-
$SRC = "$ROOT/src"
10-
$GCM_SRC = "$SRC/shared/Git-Credential-Manager"
7+
$THISDIR = $PSScriptRoot
8+
$ROOT = (Get-Item $THISDIR).Parent.Parent.Parent.FullName
9+
$SRC = "$ROOT\src"
10+
$GCM_SRC = "$SRC\shared\Git-Credential-Manager"
1111

1212
# Perform pre-execution checks
13-
$PAYLOAD = "$OUTPUT"
14-
if ($SYMBOLOUTPUT)
13+
$PAYLOAD = "$Output"
14+
if ($SymbolOutput)
15+
{
16+
$SYMBOLS = "$SymbolOutput"
17+
}
18+
else
1519
{
16-
$SYMBOLS = "$SYMBOLOUTPUT"
17-
} else {
1820
$SYMBOLS = "$PAYLOAD.sym"
1921
}
2022

@@ -32,37 +34,37 @@ if (Test-Path -Path $SYMBOLS)
3234
}
3335

3436
# Ensure payload and symbol directories exist
35-
mkdir -p "$PAYLOAD","$SYMBOLS"
37+
mkdir -p "$PAYLOAD","$SYMBOLS" | Out-Null
3638

3739
# Publish core application executables
3840
Write-Output "Publishing core application..."
3941
dotnet publish "$GCM_SRC" `
4042
--framework net472 `
41-
--configuration "$CONFIGURATION" `
43+
--configuration "$Configuration" `
4244
--runtime win-x86 `
4345
--output "$PAYLOAD"
4446

4547
# Delete libraries that are not needed for Windows but find their way
4648
# into the publish output.
47-
Remove-Item -Path "$PAYLOAD/*.dylib" -Force
49+
Remove-Item -Path "$PAYLOAD/*.dylib" -Force -ErrorAction Ignore
4850

4951
# Delete extraneous files that get included for other architectures
5052
# We only care about x86 as the core GCM executable is only targeting x86
51-
Remove-Item -Path "$PAYLOAD/arm/" -Recurse -Force
52-
Remove-Item -Path "$PAYLOAD/arm64/" -Recurse -Force
53-
Remove-Item -Path "$PAYLOAD/x64/" -Recurse -Force
54-
Remove-Item -Path "$PAYLOAD/musl-x64/" -Recurse -Force
55-
Remove-Item -Path "$PAYLOAD/runtimes/win-arm64/" -Recurse -Force
56-
Remove-Item -Path "$PAYLOAD/runtimes/win-x64/" -Recurse -Force
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
56+
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
5759

5860
# The Avalonia and MSAL binaries in these directories are already included in
5961
# the $PAYLOAD directory directly, so we can delete these extra copies.
60-
Remove-Item -Path "$PAYLOAD/x86/libSkiaSharp.dll" -Recurse -Force
61-
Remove-Item -Path "$PAYLOAD/x86/libHarfBuzzSharp.dll" -Recurse -Force
62-
Remove-Item -Path "$PAYLOAD/runtimes/win-x86/native/msalruntime_x86.dll" -Recurse -Force
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
6365

6466
# Delete localized resource assemblies - we don't localize the core GCM assembly anyway
65-
Get-ChildItem "$PAYLOAD" -Recurse -Include "*.resources.dll" | Remove-Item -Force
67+
Get-ChildItem "$PAYLOAD" -Recurse -Include "*.resources.dll" | Remove-Item -Force -ErrorAction Ignore
6668

6769
# Delete any empty directories
6870
Get-ChildItem "$PAYLOAD" -Recurse -Directory `

0 commit comments

Comments
 (0)