-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.ps1
92 lines (76 loc) · 2.79 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
param([Parameter(Position=0)]$cmd, $configuration=$env:CONFIGURATION, $platform=$env:PLATFORM, $ci=$False)
if (!$configuration) {
$configuration = "Release"
}
if (!$platform) {
$platform = "x64"
}
$root = $PSScriptRoot
$projectName = 'AudioDeviceSwitcher'
$package_dir = "$root/src/$projectName (Package)"
$certificatePath = "$root/$projectName.pfx"
$sign = (Test-Path $certificatePath)
function Create-Package {
msbuild -v:m -nologo `
-p:Configuration=$configuration `
-p:Platform=$platform `
-p:AppxPackageSigningEnabled=$sign `
-p:AppxBundlePlatforms=$platform `
-p:AppPublishSingleFile=true `
-p:UapAppxPackageBuildMode=StoreUpload
}
function Install-Audio-Devices {
$url = "https://download.vb-audio.com/Download_CABLE/VBCABLE_Driver_Pack43.zip"
$installDir = "$root/VB-Cable"
$zip = "$root/VB-Cable.zip"
$instances = 2
Set-Service -Name "Audiosrv" -StartupType Automatic
Start-Service Audiosrv
New-Item -ItemType Directory -Force -Path $installDir
Invoke-WebRequest $url -OutFile $zip
Expand-Archive -LiteralPath $zip -DestinationPath $installDir
$cert = (Get-AuthenticodeSignature "$installDir/vbaudio_cable64_win7.sys").SignerCertificate
$store = [System.Security.Cryptography.X509Certificates.X509Store]::new("TrustedPublisher", "LocalMachine")
$store.Open("ReadWrite")
$store.Add($cert)
$store.Close()
for ($i = 0; $i -lt $instances; $i++)
{
&"$root/util/devcon" install "$installDir/vbMmeCable64_win7.inf" VBAudioVACWDM
}
exit 0
}
function Set-Package-Version {
[xml]$manifest = Get-Content "$package_dir/Package.appxmanifest"
$manifest.Package.Identity.Version = "$env:NBGV_SimpleVersion.0"
$manifest.save("$package_dir/Package.appxmanifest")
}
function Restore {
msbuild -v:m -nologo -p:Configuration=$configuration -p:Platform=$platform -t:restore
}
function Test {
dotnet test test/AudioDeviceSwitcher.Tests.csproj -v:m -nologo -p:Configuration=$configuration -p:Platform=$platform
}
function Coverage {
$dir = "$root/TestResults"
Remove-Item $dir -Force -Recurse -ErrorAction SilentlyContinue
dotnet test test/AudioDeviceSwitcher.Tests.csproj -v:m -nologo -p:Configuration=$configuration -p:Platform=$platform --collect "XPlat Code Coverage" -r $dir --settings coverage.runsettings
$result = (Get-Item TestResults/**/*.xml).FullName
reportgenerator -reports:$result -targetdir:$dir -reporttypes html
Start-Process "$dir/index.html"
}
function Create-Certificate {
Set-Content -Path "${projectName}.txt" -Value "$env:CERTIFICATE"
certutil -decode "${projectName}.txt" "${projectName}.pfx"
Remove-Item "${projectName}.txt"
}
switch ($cmd)
{
"restore" { Restore }
"test" { Test }
"coverage" { Coverage }
"install-audio-devices" { Install-Audio-Devices }
"set-package-version" { Set-Package-Version }
"create-certificate" { Create-Certificate }
default { Create-Package }
}