-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathrelease.ps1
More file actions
61 lines (52 loc) · 2.3 KB
/
release.ps1
File metadata and controls
61 lines (52 loc) · 2.3 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
$msBuild = "msbuild"
try
{
& $msBuild /version
Write-Host "Likely on Linux/macOS."
}
catch
{
Write-Host "MSBuild doesn't exist. Use vswhere to locate MSBuild."
# Use environment-aware path for Program Files (x86) with fallback to Program Files
$programFilesX86 = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::ProgramFilesX86)
if ([string]::IsNullOrEmpty($programFilesX86)) {
$programFilesX86 = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::ProgramFiles)
}
$vswhere = Join-Path $programFilesX86 "Microsoft Visual Studio\Installer\vswhere.exe"
if (Test-Path $vswhere)
{
# Query vswhere for the latest instance that has MSBuild
$installDir = & $vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath 2>$null
if ($installDir)
{
# Prefer the Current MSBuild path, fall back to 15.0 if needed
$candidate1 = Join-Path $installDir "MSBuild\Current\Bin\MSBuild.exe"
$candidate2 = Join-Path $installDir "MSBuild\15.0\Bin\MSBuild.exe"
if (Test-Path $candidate1) { $msBuild = $candidate1 }
elseif (Test-Path $candidate2) { $msBuild = $candidate2 }
else { Write-Host "MSBuild not found under installation path returned by vswhere: $installDir" }
}
else
{
Write-Host "vswhere found but no suitable Visual Studio instance with MSBuild component."
}
}
else
{
Write-Host "vswhere not found at '$vswhere'. Falling back to VSSetup module."
Install-Module VSSetup -Scope CurrentUser -Force
$instance = Get-VSSetupInstance -All | Select-VSSetupInstance -Require 'Microsoft.Component.MSBuild' -Latest
$installDir = $instance.installationPath
$msBuild = Join-Path $installDir 'MSBuild\15.0\Bin\MSBuild.exe'
}
if (-not [string]::IsNullOrEmpty($msBuild) -and -not ([System.IO.File]::Exists($msBuild)))
{
Write-Host "MSBuild doesn't exist. Exit."
exit 1
}
Write-Host "Likely on Windows."
}
Write-Host "MSBuild found. Compile the projects."
& $msBuild BasicExample.slnx /t:restore /p:Configuration=Release
& $msBuild BasicExample.slnx /p:Configuration=Release
Write-Host "Compilation finished."