forked from clowd/Clowd.Squirrel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
58 lines (48 loc) · 2.6 KB
/
build.ps1
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
# Stop the script if an error occurs
$ProgressPreference = "SilentlyContinue" # progress bar in powershell is slow af
$ErrorActionPreference = "Stop"
# This variable is null in github actions
if ($PSScriptRoot -eq $null) {
$PSScriptRoot = "."
} else {
Set-Location $PSScriptRoot
}
# search for msbuild, the loaction of vswhere is guarenteed to be consistent
$MSBuildPath = (&"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe) | Out-String
Set-Alias msbuild $MSBuildPath.Trim()
Set-Alias seven "$PSScriptRoot\vendor\7za.exe"
# Ensure a clean state by removing build/package folders
Write-Host "Cleaning previous build outputs (if any)" -ForegroundColor Magenta
$Folders = @("build", "packages", "test\bin", "test\obj")
foreach ($Folder in $Folders) {
if (Test-Path $Folder) {
Remove-Item -path "$Folder" -Recurse -Force
}
}
Write-Host "Retrieving current version from nbgv" -ForegroundColor Magenta
$gitVerJson = (&nbgv get-version -f json) | ConvertFrom-Json
$version = $gitVerJson.NuGetPackageVersion
$version
# Build solution with msbuild as dotnet can't build C++
Write-Host "Building Solution" -ForegroundColor Magenta
msbuild /verbosity:minimal /restore /p:Configuration=Release
# Build single-exe packaged projects and drop into nupkg
Write-Host "Extracting Generated Packages" -ForegroundColor Magenta
Set-Location "$PSScriptRoot\build\Release"
seven x Clowd.Squirrel*.nupkg -osquirrel
Remove-Item Clowd.Squirrel*.nupkg
Write-Host "Publishing SingleFile Projects" -ForegroundColor Magenta
$ToolsDir = "squirrel\tools"
dotnet publish -v minimal --no-build -c Release --no-self-contained "$PSScriptRoot\src\Squirrel.CommandLine\Squirrel.CommandLine.csproj" -o "$ToolsDir"
dotnet publish -v minimal --no-build -c Release --self-contained "$PSScriptRoot\src\Update.Windows\Update.Windows.csproj" -o "$ToolsDir"
dotnet publish -v minimal --no-build -c Release --self-contained "$PSScriptRoot\src\Update.OSX\Update.OSX.csproj" -o "$ToolsDir"
Write-Host "Copying Tools" -ForegroundColor Magenta
# Copy all the tools into the 'csq' package
Copy-Item -Path "$PSScriptRoot\vendor\*" -Destination $ToolsDir -Recurse
Copy-Item -Path "Win32\*" -Destination $ToolsDir
Copy-Item -Path "$PSScriptRoot\Squirrel.entitlements" -Destination "$ToolsDir"
Remove-Item "$ToolsDir\*.pdb"
Remove-Item "$ToolsDir\7za.exe"
Write-Host "Re-assembling Packages" -ForegroundColor Magenta
seven a "Clowd.Squirrel.$version.nupkg" -tzip -mx9 "$PSScriptRoot\build\Release\squirrel\*"
Write-Host "Done." -ForegroundColor Magenta