-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-host.ps1
28 lines (22 loc) · 1.04 KB
/
build-host.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
param (
[string]$PathToSrc,
[string]$OutputDir = "./Hosts",
[string]$Arch = "x64",
[string]$Configuration = "Release"
)
$csprojPath = "$PathToSrc/Host/Host.csproj"
# Restore and build project
MSBuild.exe $csprojPath -t:restore -verbosity:minimal
MSBuild.exe $csprojPath -p:Configuration=$Configuration -p:Platform=$Arch -verbosity:minimal
$regex = [System.Text.RegularExpressions.Regex]::new("^\s*\[assembly:\s*AssemblyVersion\s*\(\s*`"(\d+\.\d+.\d+)`"\s*\)\s*\]");
# Finds version string in the AssemblyInfo.cs
$version = Get-Content "$PathToSrc/Host/Properties/AssemblyInfo.cs" | `
ForEach-Object {$regex.Matches($_)} | `
Where-Object {$_.Success} | `
ForEach-Object {$_.Groups[1].Value}
# Creates output directory if it is missing
$dir = "$OutputDir/Host_$($Configuration)_$($Arch)_v$version"
New-Item $dir -Force -ItemType Directory -ErrorAction SilentlyContinue
# Copies items one by one
Get-ChildItem "$PathToSrc/Host/bin/$Arch/$Configuration/" | `
ForEach-Object {Copy-Item -Path $($_.FullName) -Destination "$dir\"}