imnyang/BlockModLoader
Archived
Watch
2
0
Fork
You've already forked BlockModLoader
0
This repository has been archived on 2026-10-08. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
BlockModLoader/build.ps1
2026-10-05 12:57:50 +09:00

42 lines
2 KiB
PowerShell

param(
[string]$MSBuildPath,
[switch]$Test
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
Push-Location $PSScriptRoot
try {
if (!$MSBuildPath) {
$command = Get-Command MSBuild.exe -ErrorAction SilentlyContinue
if ($command) { $MSBuildPath = $command.Source }
else {
$rider = Get-ChildItem "${env:ProgramFiles}/JetBrains" -Filter 'JetBrains Rider *' -Directory -ErrorAction SilentlyContinue |
Sort-Object Name -Descending | Select-Object -First 1
if ($rider) { $MSBuildPath = Join-Path $rider.FullName 'tools/MSBuild/Current/Bin/MSBuild.exe' }
}
}
if (!$MSBuildPath -or !(Test-Path -LiteralPath $MSBuildPath)) {
throw 'Pass -MSBuildPath with Visual Studio or Rider MSBuild.exe.'
}
if (!(Test-Path -LiteralPath 'packages/net48/build/.NETFramework/v4.8/mscorlib.dll')) {
New-Item -ItemType Directory -Force -Path 'packages/net48' | Out-Null
$archive = Join-Path $PSScriptRoot 'packages/net48/package.zip'
Invoke-WebRequest 'https://api.nuget.org/v3-flatcontainer/microsoft.netframework.referenceassemblies.net48/1.0.3/microsoft.netframework.referenceassemblies.net48.1.0.3.nupkg' -OutFile $archive
Expand-Archive -LiteralPath $archive -DestinationPath 'packages/net48' -Force
Remove-Item -LiteralPath $archive
}
& $MSBuildPath BlockMelonLoader.csproj /restore '/t:Rebuild,Pack' /p:Configuration=Release /v:minimal /nologo
if ($LASTEXITCODE -ne 0) { throw 'Library build failed.' }
if ($Test) {
& $MSBuildPath Tests/BlockMelonLoader.Tests.csproj /t:Rebuild /v:minimal /nologo
if ($LASTEXITCODE -ne 0) { throw 'Test build failed.' }
& ./Tests/bin/Release/BlockMelonLoader.Tests.exe
if ($LASTEXITCODE -ne 0) { throw 'Tests failed.' }
}
Write-Host "Library output: $PSScriptRoot/bin/Release/BlockMelonLoader.dll"
Write-Host "NuGet output: $PSScriptRoot/artifacts/BlockMelonLoader.1.0.0.nupkg"
}
finally { Pop-Location }