-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.ps1
More file actions
78 lines (67 loc) · 2.7 KB
/
build.ps1
File metadata and controls
78 lines (67 loc) · 2.7 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Param(
[string]$ProjectFolder = $PSScriptRoot,
[string]$Configuration = "Release",
[string]$SolutionPath = "",
[string]$MsbuildPath = "C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\MSBuild.exe",
[string]$OutputDir = "",
[switch]$SkipIceValidation
)
$ErrorActionPreference = "Stop"
$ProjectFolder = (Resolve-Path $ProjectFolder).Path
if ([string]::IsNullOrWhiteSpace($SolutionPath)) {
$SolutionPath = Join-Path $ProjectFolder "NcTalkOutlookAddIn.sln"
}
if ([string]::IsNullOrWhiteSpace($OutputDir)) {
$OutputDir = Join-Path $ProjectFolder "dist"
}
if (-not (Test-Path $MsbuildPath)) {
throw "MSBuild.exe not found at $MsbuildPath"
}
if (-not (Test-Path $SolutionPath)) {
throw "Solution not found at $SolutionPath"
}
Write-Host "Building solution using $MsbuildPath ($Configuration)..."
& $MsbuildPath $SolutionPath "/m" "/t:Rebuild" "/p:Configuration=$Configuration" | Out-Host
if ($LASTEXITCODE -ne 0) {
throw "MSBuild exited with code $LASTEXITCODE."
}
$buildOutputDir = Join-Path $ProjectFolder "src\\NcTalkOutlookAddIn\\bin\\$Configuration"
$dllPath = Join-Path $buildOutputDir "NcTalkOutlookAddIn.dll"
if (-not (Test-Path $dllPath)) {
throw "Build succeeded but assembly not found at $dllPath."
}
$assemblyInfo = [System.Reflection.AssemblyName]::GetAssemblyName($dllPath).Version
$assemblyVersionFull = $assemblyInfo.ToString()
$assemblyVersionShort = "{0}.{1}.{2}" -f $assemblyInfo.Major, $assemblyInfo.Minor, $assemblyInfo.Build
Write-Host "Assembly version detected: $assemblyVersionFull"
$wixProject = Join-Path $ProjectFolder "installer\\NcConnectorOutlookInstaller.wixproj"
if (-not (Test-Path $wixProject)) {
throw "WiX project not found at $wixProject."
}
Write-Host "Building MSI via WiX v4 SDK (dotnet build)..."
$wixArgs = @(
"build",
$wixProject,
"-c",
$Configuration,
"/p:BuildOutputDir=$buildOutputDir\\",
"/p:ProductVersion=$assemblyVersionShort",
"/p:AssemblyVersion=$assemblyVersionFull"
)
if ($SkipIceValidation) {
# Useful on environments where Windows Installer ICE execution is unavailable (WIX0217).
$wixArgs += "/p:SuppressValidation=true"
}
& dotnet @wixArgs | Out-Host
if ($LASTEXITCODE -ne 0) {
throw "dotnet build (WiX) exited with code $LASTEXITCODE."
}
$builtMsiPath = Join-Path $ProjectFolder "installer\\bin\\$Configuration\\NCConnectorForOutlook.msi"
if (-not (Test-Path $builtMsiPath)) {
throw "MSI build succeeded but output not found at $builtMsiPath."
}
New-Item -ItemType Directory -Force -Path $OutputDir | Out-Null
$finalName = "NCConnectorForOutlook-$assemblyVersionShort.msi"
$finalPath = Join-Path $OutputDir $finalName
Copy-Item -Force $builtMsiPath $finalPath
Write-Host "MSI erstellt: $finalPath"