-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-packages.ps1
More file actions
58 lines (44 loc) · 1.92 KB
/
build-packages.ps1
File metadata and controls
58 lines (44 loc) · 1.92 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
#!/usr/bin/env pwsh
# Build script for creating NuGet packages
param(
[string]$Configuration = "Release",
[string]$OutputPath = "./artifacts"
)
Write-Host "Building AnAspect.OneOf NuGet packages..." -ForegroundColor Cyan
# Clean previous builds
Write-Host "`nCleaning previous builds..." -ForegroundColor Yellow
dotnet clean OneOf.sln -c $Configuration
# Restore dependencies
Write-Host "`nRestoring dependencies..." -ForegroundColor Yellow
dotnet restore OneOf.sln
# Build solution
Write-Host "`nBuilding solution..." -ForegroundColor Yellow
dotnet build OneOf.sln -c $Configuration --no-restore
# Run tests
Write-Host "`nRunning tests..." -ForegroundColor Yellow
dotnet test tests/AnAspect.OneOf.Tests/AnAspect.OneOf.Tests.csproj -c $Configuration --no-build
if ($LASTEXITCODE -ne 0) {
Write-Host "Tests failed! Aborting package creation." -ForegroundColor Red
exit 1
}
# Create output directory
New-Item -ItemType Directory -Force -Path $OutputPath | Out-Null
# Pack projects
Write-Host "`nCreating NuGet packages..." -ForegroundColor Yellow
$projects = @(
"src/AnAspect.OneOf.Attributes/AnAspect.OneOf.Attributes.csproj",
"src/AnAspect.OneOf.SourceGenerator/AnAspect.OneOf.SourceGenerator.csproj",
"src/AnAspect.OneOf.Fody/AnAspect.OneOf.Fody.csproj"
)
foreach ($project in $projects) {
Write-Host " Packing $project..." -ForegroundColor Gray
dotnet pack $project -c $Configuration --no-build --output $OutputPath
}
Write-Host "`n✓ Packages created successfully in $OutputPath" -ForegroundColor Green
Write-Host "`nTo publish to NuGet:" -ForegroundColor Cyan
Write-Host " dotnet nuget push `"$OutputPath/*.nupkg`" --api-key YOUR_API_KEY --source https://api.nuget.org/v3/index.json" -ForegroundColor Gray
# List created packages
Write-Host "`nCreated packages:" -ForegroundColor Cyan
Get-ChildItem -Path $OutputPath -Filter "*.nupkg" | ForEach-Object {
Write-Host " - $($_.Name)" -ForegroundColor White
}