forked from 1Remote/1Remote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prm.build.ps1
69 lines (58 loc) · 2.13 KB
/
prm.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
59
60
61
62
63
64
65
66
67
68
69
<# .PARAMETER ib #>
param (
[ValidateSet('Debug', 'Release')]
[string] $aReleaseType = 'Release'
)
Enter-Build {
$ProjectName = Split-Path $pwd -Leaf
$msbuild = Resolve-MSBuild
Write-Host "Using msbuild: $msbuild"
Set-Alias MSBuild $msbuild -Scope Global
}
# Synopsis: Ensure local dependencies
task Deps {
if (!(Test-Admin)) { throw "This task must be run in administrative shell" }
if (!(Get-Command choco.exe -ErrorAction 0)) {
Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression
} else { Write-Host "Chocolatey already installed" }
exec {
#choco install -y dotnetfx --version 4.8.0.20190930
#choco install -y visualstudio2019buildtools
#choco install -y visualstudio2019-workload-universal
#choco install -y windows-sdk-10-version-1809-all
choco install -y visualstudio2022community
choco install -y dotnet-6.0-sdk
choco install -y visualstudio2022-workload-manageddesktop
choco install -y visualstudio2022-workload-universal
# optional
# choco install -y git
}
}
# Synopsis: Build the application
task Build {
if (($f = [System.IO.Directory]::GetFiles($pwd, '*.sln')).Length -eq 1) {
$SolutionPath = $f[0]
}
exec { MSBuild $SolutionPath /t:Build /ignoreprojectextensions:.csproj /property:Configuration=$aReleaseType }
}
# Synopsis: Build in Windows Sandbox
task BuildInSandbox {
.\scripts\Test-Sandbox.ps1 -MapFolder $pwd -Script "
cd `$Env:USERPROFILE\Desktop\$ProjectName
Set-Alias ib `$pwd\Invoke-Build.ps1
ib Deps
ib Build
"
}
# Synopsis: Clean generated data
task Clean {
if (($f = [System.IO.Directory]::GetFiles($pwd, '*.sln')).Length -eq 1) {
$SolutionPath = $f[0]
}
exec { MSBuild $SolutionPath /t:Clean /property:Configuration=$aReleaseType }
}
# Test for administration privileges
function Test-Admin() {
$usercontext = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
$usercontext.IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
}