61 lines
2.1 KiB
PowerShell
61 lines
2.1 KiB
PowerShell
param(
|
|
[string]$Configuration = "Release",
|
|
[switch]$CreateDeploymentPackage
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$repoRoot = Split-Path -Parent $scriptDir
|
|
$solutionPath = Join-Path $repoRoot "HostAvailabilityMonitor.sln"
|
|
|
|
function Get-MSBuildPath {
|
|
$msbuildFromPath = Get-Command msbuild.exe -ErrorAction SilentlyContinue
|
|
if ($msbuildFromPath) {
|
|
return $msbuildFromPath.Source
|
|
}
|
|
|
|
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
|
|
if (Test-Path $vswhere) {
|
|
$installationPath = & $vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
|
|
if ($installationPath) {
|
|
$candidate = Join-Path $installationPath "MSBuild\Current\Bin\MSBuild.exe"
|
|
if (Test-Path $candidate) {
|
|
return $candidate
|
|
}
|
|
}
|
|
}
|
|
|
|
throw "MSBuild.exe wurde nicht gefunden. Bitte Visual Studio Build Tools oder Visual Studio installieren."
|
|
}
|
|
|
|
$msbuild = Get-MSBuildPath
|
|
Write-Host "Verwende MSBuild: $msbuild"
|
|
|
|
& $msbuild $solutionPath /t:Build /p:Configuration=$Configuration /p:Platform="Any CPU"
|
|
|
|
$publishRoot = Join-Path $repoRoot "artifacts\publish\net472"
|
|
if (Test-Path $publishRoot) {
|
|
Remove-Item -Path $publishRoot -Recurse -Force
|
|
}
|
|
New-Item -ItemType Directory -Path $publishRoot | Out-Null
|
|
|
|
$projects = @(
|
|
@{ Name = "HostAvailabilityMonitor"; ProjectDir = Join-Path $repoRoot "src\HostAvailabilityMonitor" },
|
|
@{ Name = "BizTalkMonitorConfigGenerator"; ProjectDir = Join-Path $repoRoot "src\BizTalkMonitorConfigGenerator" }
|
|
)
|
|
|
|
foreach ($project in $projects) {
|
|
$outputDir = Join-Path $project.ProjectDir "bin\$Configuration"
|
|
$targetDir = Join-Path $publishRoot $project.Name
|
|
New-Item -ItemType Directory -Path $targetDir -Force | Out-Null
|
|
Copy-Item -Path (Join-Path $outputDir "*") -Destination $targetDir -Recurse -Force
|
|
Write-Host "Publish-Verzeichnis für $($project.Name): $targetDir"
|
|
}
|
|
|
|
Write-Host "Build abgeschlossen. Publish-Root: $publishRoot"
|
|
|
|
if ($CreateDeploymentPackage) {
|
|
& (Join-Path $scriptDir 'package-deployment.ps1') -PublishRoot '.\artifacts\publish\net472'
|
|
}
|