-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpackage.ps1
More file actions
45 lines (39 loc) · 1.78 KB
/
package.ps1
File metadata and controls
45 lines (39 loc) · 1.78 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
# Define target runtimes
$runtimes = @(
@{ Name = "win-x64"; Platform = "Windows" },
@{ Name = "linux-x64"; Platform = "Linux" },
@{ Name = "osx-x64"; Platform = "macOS" }
)
# Get the version from the project file
$projectFile = Get-ChildItem -Path . -Filter "*.csproj" | Select-Object -First 1
if ($projectFile) {
[xml]$xmlContent = Get-Content $projectFile.FullName
$version = $xmlContent.Project.PropertyGroup.Version
if ($version) {
Write-Host "Version: $version"
# Build and package for each runtime
foreach ($runtime in $runtimes) {
Write-Host "Building for $($runtime.Platform) ($($runtime.Name))..."
# Create platform-specific output directory
$outputDir = "./publish/$($runtime.Name)"
# Publish for specific runtime
dotnet publish uhigh.csproj -c Release -r $($runtime.Name) --self-contained true -o $outputDir
if ($LASTEXITCODE -eq 0) {
# Create platform-specific zip file
$zipFileName = "uhigh-$version-$($runtime.Name).zip"
$zipFilePath = Join-Path -Path (Get-Location) -ChildPath $zipFileName
Compress-Archive -Path "$outputDir/*" -DestinationPath $zipFilePath -Force
Write-Host "Package created: $zipFilePath"
} else {
Write-Host "Failed to build for $($runtime.Platform)" -ForegroundColor Red
}
}
} else {
Write-Host "Version not found in project file." -ForegroundColor Red
}
} else {
Write-Host "No project file found." -ForegroundColor Red
}
# Clean up publish directory
Remove-Item -Path "./publish" -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "Build process completed."