-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTest.ps1
More file actions
129 lines (110 loc) · 4.15 KB
/
Test.ps1
File metadata and controls
129 lines (110 loc) · 4.15 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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<#
.Description
For a full test, try this
.\Test.ps1 -reinstall -mode new
For just a reinstall
.\Test.ps1 -reinstall
To test the templates without build/reinstall
.\Test.ps1 -mode run_in_place
#>
param(
[ValidateSet('run_in_place','build_in_place','new','none')]
[string]$mode = 'none',
[ValidateSet('all','sk-multi','sk-net','sk-sketch')]
[string]$template = 'all',
[switch]$reinstall = $false
)
$fileData = Get-Content -path "$PSScriptRoot/StereoKit.Templates.csproj" -Raw;
$fileData -match '<PackageVersion>(?<ver>.*)</PackageVersion>' | Out-Null
$version = $Matches.ver
Write-Host "Testing StereoKit.Templates $version"
if ($reinstall -eq $true) {
& dotnet new uninstall StereoKit.Templates
& dotnet pack --configuration Release
& dotnet new install "$PSScriptRoot/bin/Release/StereoKit.Templates.$version.nupkg"
}
if ($mode -eq 'run_in_place') {
if ($template -eq 'all' -or $template -eq 'sk-multi') {
Push-Location -Path "$PSScriptRoot/templates/SKTemplate_Multi"
& dotnet run
& dotnet publish -c Release Projects/Android/SKTemplate_Multi_Android.csproj
Pop-Location
if ($LASTEXITCODE -ne 0) { return $LASTEXITCODE }
}
if ($template -eq 'all' -or $template -eq 'sk-net') {
Push-Location -Path "$PSScriptRoot/templates/SKTemplate_Net"
& dotnet run
Pop-Location
if ($LASTEXITCODE -ne 0) { return $LASTEXITCODE }
}
if ($template -eq 'all' -or $template -eq 'sk-net') {
Push-Location -Path "$PSScriptRoot/templates/SKTemplate_Sketch"
& dotnet run
Pop-Location
if ($LASTEXITCODE -ne 0) { return $LASTEXITCODE }
}
} elseif ($mode -eq 'build_in_place') {
if ($template -eq 'all' -or $template -eq 'sk-multi') {
Push-Location -Path "$PSScriptRoot/templates/SKTemplate_Multi"
& dotnet workload restore
& dotnet build
& dotnet publish -c Release Projects/Android/SKTemplate_Multi_Android.csproj
Pop-Location
if ($LASTEXITCODE -ne 0) { return $LASTEXITCODE }
}
if ($template -eq 'all' -or $template -eq 'sk-net') {
Push-Location -Path "$PSScriptRoot/templates/SKTemplate_Net"
& dotnet build
Pop-Location
if ($LASTEXITCODE -ne 0) { return $LASTEXITCODE }
}
if ($template -eq 'all' -or $template -eq 'sk-sketch') {
Push-Location -Path "$PSScriptRoot/templates/SKTemplate_Sketch"
& dotnet build
Pop-Location
if ($LASTEXITCODE -ne 0) { return $LASTEXITCODE }
}
} elseif($mode -eq 'new') {
if (!(Test-Path -Path 'test')) {
New-Item -Path . -Name 'test' -ItemType "directory" | Out-Null
}
Push-Location -Path "$PSScriptRoot/test"
$multiName = 'Multi-with_Crazy name'
if (!(Test-Path -Path $multiName)) {
New-Item -Path . -Name $multiName -ItemType "directory" | Out-Null
}
$netName = "net project_Name"
if (!(Test-Path -Path $netName)) {
New-Item -Path . -Name $netName -ItemType "directory" | Out-Null
}
$sketchName = "Sketch Project"
if (!(Test-Path -Path $sketchName)) {
New-Item -Path . -Name $sketchName -ItemType "directory" | Out-Null
}
Pop-Location
if ($template -eq 'all' -or $template -eq 'sk-multi') {
Write-Host "## Testing sk-multi ##"
Push-Location -Path "$PSScriptRoot/test/$multiName"
& dotnet new sk-multi --allow-scripts Yes
Write-Host "## Testing sk-multi - desktop ##"
& dotnet run
Write-Host "## Testing sk-multi - android ##"
& dotnet publish -c Release "Projects/Android/$($multiName).Android.csproj"
Pop-Location
}
if ($template -eq 'all' -or $template -eq 'sk-net') {
Write-Host "## Testing sk-net ##"
Push-Location -Path "$PSScriptRoot/test/$netName"
& dotnet new sk-net
& dotnet run
Pop-Location
}
if ($template -eq 'all' -or $template -eq 'sk-sketch') {
Write-Host "## Testing sk-sketch ##"
Push-Location -Path "$PSScriptRoot/test/$sketchName"
& dotnet new sk-sketch
& dotnet run
Pop-Location
}
Remove-Item -Path "$PSScriptRoot/test" -Recurse -Force | Out-Null
}