-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathbuild.ps1
More file actions
107 lines (93 loc) · 3.09 KB
/
build.ps1
File metadata and controls
107 lines (93 loc) · 3.09 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
#!/usr/bin/env pwsh
param(
[string]$Configuration = "Release",
[switch]$Clean,
[switch]$Test,
[switch]$Pack,
[switch]$Help
)
if ($Help) {
Write-Host @"
NFC Reader Library Build Script
Usage: .\build.ps1 [options]
Options:
-Configuration <config> Build configuration (Debug|Release) [default: Release]
-Clean Clean build artifacts before building
-Test Run tests after building
-Pack Create NuGet package after building
-Help Show this help message
Examples:
.\build.ps1 # Build in Release mode
.\build.ps1 -Configuration Debug # Build in Debug mode
.\build.ps1 -Clean -Test # Clean, build, and test
.\build.ps1 -Clean -Test -Pack # Clean, build, test, and package
"@
exit 0
}
Write-Host "NFC Reader Library Build Script" -ForegroundColor Green
Write-Host "===============================" -ForegroundColor Green
Write-Host ""
# Check if .NET is installed
try {
$dotnetVersion = dotnet --version
Write-Host "Using .NET SDK version: $dotnetVersion" -ForegroundColor Yellow
} catch {
Write-Error ".NET SDK not found. Please install .NET 6.0 or later."
exit 1
}
# Clean if requested
if ($Clean) {
Write-Host "Cleaning build artifacts..." -ForegroundColor Yellow
dotnet clean
if ($LASTEXITCODE -ne 0) {
Write-Error "Clean failed"
exit 1
}
Write-Host "Clean completed successfully" -ForegroundColor Green
}
# Restore dependencies
Write-Host "Restoring dependencies..." -ForegroundColor Yellow
dotnet restore
if ($LASTEXITCODE -ne 0) {
Write-Error "Restore failed"
exit 1
}
Write-Host "Dependencies restored successfully" -ForegroundColor Green
# Build main project
Write-Host "Building main project..." -ForegroundColor Yellow
dotnet build --configuration $Configuration --no-restore
if ($LASTEXITCODE -ne 0) {
Write-Error "Build failed"
exit 1
}
Write-Host "Build completed successfully" -ForegroundColor Green
# Build examples
Write-Host "Building examples..." -ForegroundColor Yellow
dotnet build Examples/Examples.csproj --configuration $Configuration --no-restore
if ($LASTEXITCODE -ne 0) {
Write-Error "Examples build failed"
exit 1
}
Write-Host "Examples built successfully" -ForegroundColor Green
# Run tests if requested
if ($Test) {
Write-Host "Running tests..." -ForegroundColor Yellow
dotnet test --configuration $Configuration --no-build --verbosity normal
if ($LASTEXITCODE -ne 0) {
Write-Error "Tests failed"
exit 1
}
Write-Host "Tests completed successfully" -ForegroundColor Green
}
# Create package if requested
if ($Pack) {
Write-Host "Creating NuGet package..." -ForegroundColor Yellow
dotnet pack NFCReader.csproj --configuration $Configuration --no-build --output ./nupkg
if ($LASTEXITCODE -ne 0) {
Write-Error "Package creation failed"
exit 1
}
Write-Host "Package created successfully in ./nupkg directory" -ForegroundColor Green
}
Write-Host ""
Write-Host "Build completed successfully!" -ForegroundColor Green