Skip to content

Commit 04f0790

Browse files
committed
Install ref package
1 parent a15fdfc commit 04f0790

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<#
2+
.SYNOPSIS
3+
Unzips an AspNetCore.App.Ref nupkg
4+
.DESCRIPTION
5+
This script unzips an AspNetCore.App.Ref nupkg
6+
.PARAMETER RefPath
7+
The path to the AspNetCore.App.Ref package to install.
8+
.PARAMETER InstallDir
9+
The directory to install to.
10+
#>
11+
param(
12+
[Parameter(Mandatory = $true)]
13+
$RefPath,
14+
15+
[Parameter(Mandatory = $true)]
16+
$InstallDir,
17+
)
18+
19+
$ErrorActionPreference = 'Stop'
20+
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138
21+
22+
Set-StrictMode -Version 1
23+
24+
Write-Host "Extracting to $InstallDir"
25+
26+
$zipPackage = [io.path]::ChangeExtension($RefPath, ".zip")
27+
Write-Host "Renaming to $zipPackage"
28+
Rename-Item -Path $RefPath -NewName $zipPackage
29+
if (Get-Command -Name 'Microsoft.PowerShell.Archive\Expand-Archive' -ErrorAction Ignore) {
30+
# Use built-in commands where possible as they are cross-plat compatible
31+
Microsoft.PowerShell.Archive\Expand-Archive -Path $zipPackage -DestinationPath "$InstallDir" -Force
32+
}
33+
else {
34+
Remove-Item "$InstallDir" -Recurse -ErrorAction Ignore
35+
# Fallback to old approach for old installations of PowerShell
36+
Add-Type -AssemblyName System.IO.Compression.FileSystem
37+
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipPackage, "$InstallDir")
38+
}
39+
40+
Get-ChildItem -Path "$InstallDir" -Recurse

0 commit comments

Comments
 (0)