-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake.ps1
More file actions
81 lines (72 loc) · 2.24 KB
/
Copy pathmake.ps1
File metadata and controls
81 lines (72 loc) · 2.24 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
param(
[ValidateSet("build", "debug", "test", "pack", "publish", "clean")]
[string]$target = "build"
)
$ErrorActionPreference = "Stop"
$basePath = $PSScriptRoot
$solutionPath = Join-Path $basePath "src\locr.sln"
$projectPath = Join-Path $basePath "src\locr\locr.csproj"
$releasePath = Join-Path $basePath "releases"
$version = (Get-Content (Join-Path $basePath "VERSION")).Trim()
function Invoke-Clean {
Write-Host "Cleaning" -ForegroundColor Blue
dotnet clean $solutionPath -c Release --nologo
Get-ChildItem -Path $basePath -Include bin, obj -Recurse -Directory |
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
if (Test-Path $releasePath) {
Remove-Item "$releasePath\*" -Recurse -Force -ErrorAction SilentlyContinue
}
}
function Invoke-Build {
param([string]$configuration = "Release")
Write-Host "Building ($configuration)" -ForegroundColor Blue
dotnet build $solutionPath -c $configuration --nologo -p:Version=$version
if ($LASTEXITCODE -ne 0) { throw "BUILD FAILED!" }
}
function Invoke-Test {
Write-Host "Testing" -ForegroundColor Blue
dotnet test $solutionPath -c Release --nologo
if ($LASTEXITCODE -ne 0) { throw "TESTS FAILED!" }
}
function Invoke-Pack {
Write-Host "Packing" -ForegroundColor Blue
dotnet pack $projectPath -c Release --nologo -p:Version=$version -o $releasePath
if ($LASTEXITCODE -ne 0) { throw "PACK FAILED!" }
}
function Invoke-Publish {
Write-Host "Publishing NuGet package" -ForegroundColor Blue
$package = Join-Path $releasePath "locr.$version.nupkg"
dotnet nuget push $package --source https://api.nuget.org/v3/index.json --api-key $env:NUGET_API_KEY
if ($LASTEXITCODE -ne 0) { throw "PUBLISH FAILED!" }
}
switch ($target) {
"clean" {
Invoke-Clean
}
"debug" {
Invoke-Clean
Invoke-Build -configuration "Debug"
}
"build" {
Invoke-Clean
Invoke-Build
Invoke-Test
}
"test" {
Invoke-Test
}
"pack" {
Invoke-Clean
Invoke-Build
Invoke-Test
Invoke-Pack
}
"publish" {
Invoke-Clean
Invoke-Build
Invoke-Test
Invoke-Pack
Invoke-Publish
}
}
Write-Host "Finished" -ForegroundColor Blue