35 lines
1.3 KiB
PowerShell
35 lines
1.3 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[ValidateSet('Debug', 'Release', 'Snapshot')]
|
|
[string]$Configuration = 'Debug'
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$solution = Join-Path $PSScriptRoot '..\Plain Craft Launcher 2.sln'
|
|
$solution = [IO.Path]::GetFullPath($solution)
|
|
|
|
$msbuild = (Get-Command msbuild.exe -ErrorAction SilentlyContinue).Source
|
|
if (-not $msbuild) {
|
|
$vswhere = @(
|
|
(Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'),
|
|
(Join-Path $env:ProgramFiles 'Microsoft Visual Studio\Installer\vswhere.exe')
|
|
) | Where-Object { Test-Path $_ } | Select-Object -First 1
|
|
|
|
if ($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) { $msbuild = $candidate }
|
|
}
|
|
}
|
|
}
|
|
|
|
if (-not $msbuild) {
|
|
throw 'MSBuild was not found. Install Visual Studio Build Tools with the .NET desktop build tools and .NET Framework 4.8 targeting pack.'
|
|
}
|
|
|
|
Write-Host "MSBuild: $msbuild"
|
|
Write-Host "Configuration: $Configuration"
|
|
& $msbuild $solution /t:Build "/p:Configuration=$Configuration" "/p:Platform=Any CPU" /m /v:minimal
|
|
exit $LASTEXITCODE
|