-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
Copy pathpublish-apps.ps1
48 lines (39 loc) · 1.64 KB
/
publish-apps.ps1
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
param($RootDirectory = (Get-Location), $Framework = "net10.0", $Runtime = "win-x64", $CommitHash, $BranchName, $BuildNumber)
# De-Powershell the path
$RootDirectory = (Convert-Path $RootDirectory)
# Find dotnet.exe
$dotnet = Join-Path (Join-Path $env:USERPROFILE ".dotnet") "dotnet.exe"
if(!(Test-Path $dotnet)) {
throw "Could not find dotnet at: $dotnet"
}
# Resolve directories
$SamplesDir = Join-Path $RootDirectory "samples"
$ArtifactsDir = Join-Path $RootDirectory "artifacts"
$AppsDir = Join-Path $ArtifactsDir "apps"
$ClientsDir = Join-Path $RootDirectory "clients"
$ClientsTsDir = Join-Path $ClientsDir "ts"
# The list of apps to publish
$Apps = @{
"SignalRSamples"= (Join-Path $SamplesDir "SignalRSamples")
"FunctionalTests"= (Join-Path $ClientsTsDir "FunctionalTests/SignalR.Client.FunctionalTestApp.csproj")
}
$BuildMetadataContent = @"
[assembly: System.Reflection.AssemblyMetadata("CommitHash", "$($CommitHash)")]
[assembly: System.Reflection.AssemblyMetadata("BranchName", "$($BranchName)")]
[assembly: System.Reflection.AssemblyMetadata("BuildNumber", "$($BuildNumber)")]
[assembly: System.Reflection.AssemblyMetadata("BuildDateUtc", "$([DateTime]::UtcNow.ToString("O"))")]
"@
$Apps.Keys | ForEach-Object {
$Name = $_
$Path = $Apps[$_]
$OutputDir = Join-Path $AppsDir $Name
# Hacky but it works for now
$MetadataPath = Join-Path $Path "BuildMetadata.cs"
$BuildMetadataContent > $MetadataPath
try {
Write-Host -ForegroundColor Green "Publishing $Name"
& "$dotnet" publish --framework $Framework --runtime $Runtime --output $OutputDir $Path
} finally {
Remove-Item $MetadataPath
}
}