-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathbuild.ps1
More file actions
54 lines (39 loc) · 1.99 KB
/
build.ps1
File metadata and controls
54 lines (39 loc) · 1.99 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
$Env:NUGET_CERT_REVOCATION_MODE = 'offline'
Push-Location $PSScriptRoot
if (Test-Path Env:PSMODULE_OUTPUT_PATH) {
$outputPath = $Env:PSMODULE_OUTPUT_PATH
}
else {
$outputPath = Join-Path $PSScriptRoot 'package'
}
$outputPath = Join-Path $outputPath 'DevolutionsGateway'
Remove-Item -Path $outputPath -Recurse -Force -ErrorAction SilentlyContinue
New-Item -Path $outputPath -ItemType 'Directory' -Force | Out-Null
@('bin', 'Public', 'Private') | % {
New-Item -Path (Join-Path $outputPath $_) -ItemType 'Directory' -Force | Out-Null
}
& dotnet nuget add source "https://api.nuget.org/v3/index.json" -n "nuget.org" | Out-Null
$gwDir = Join-Path $PSScriptRoot 'DevolutionsGateway'
$srcDir = Join-Path $gwDir 'src'
$binDir = Join-Path $gwDir 'bin' # the managed base path
$runtimesDir = Join-Path $binDir 'runtimes'
& dotnet restore $srcDir 2>&1>$null
& dotnet publish (Join-Path $srcDir 'DevolutionsGateway.csproj') -f netstandard2.0 -c Release -o $binDir
# Move and process native directories.
Get-Item "$runtimesDir\*\native*" | ForEach-Object {
$nativeDir = Join-Path $binDir $_.Parent.Name
Remove-Item $nativeDir -Recurse -ErrorAction SilentlyContinue
Move-Item $_ $nativeDir -Force
# Rename files.
Get-ChildItem $nativeDir -Recurse | Where-Object { $_.Name -match '^lib' } | ForEach-Object {
$newName = $_.Name -replace '^lib', '' # Remove "lib" prefix
Rename-Item $_.FullName -NewName $newName -Force
}
}
Remove-Item $runtimesDir -Recurse -ErrorAction SilentlyContinue
Copy-Item $binDir -Destination $outputPath -Recurse -Force -ErrorAction Stop
Copy-Item (Join-Path $gwDir 'Private') -Destination $outputPath -Recurse -Force -ErrorAction Stop
Copy-Item (Join-Path $gwDir 'Public') -Destination $outputPath -Recurse -Force -ErrorAction Stop
Copy-Item (Join-Path $gwDir 'DevolutionsGateway.psd1') -Destination $outputPath -Force -ErrorAction Stop
Copy-Item (Join-Path $gwDir 'DevolutionsGateway.psm1') -Destination $outputPath -Force -ErrorAction Stop
Pop-Location