Repository navigation
Expand file tree
/
Copy pathbuild.ps1
More file actions
54 lines (47 loc) · 1.99 KB
/
Copy pathbuild.ps1
File metadata and controls
54 lines (47 loc) · 1.99 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
<#
.SYNOPSIS
Builds ADO Lens from the source in this folder and, optionally, replaces the binaries of an installation.
.DESCRIPTION
MCP servers keep adolens.exe open, so -Deploy first stops the running processes of that installation.
After deploying, restart Claude Desktop / Claude Code sessions so they load the new version.
.EXAMPLE
.\build.ps1 # compile into .\build (the installation is not touched)
.EXAMPLE
.\build.ps1 -Test -Deploy # run the tests first; deploy only when they pass
#>
[CmdletBinding()]
param(
[string] $InstallDir = (Join-Path $env:LOCALAPPDATA 'Programs\ADO Lens'),
[switch] $Deploy,
[switch] $Test,
[ValidateSet('Debug', 'Release')]
[string] $Configuration = 'Release'
)
$ErrorActionPreference = 'Stop'
$proj = Join-Path $PSScriptRoot 'src\AdoLens\AdoLens.csproj'
$out = Join-Path $PSScriptRoot 'build'
$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'
if ($Test) {
& dotnet test (Join-Path $PSScriptRoot 'tests\AdoLens.Tests\AdoLens.Tests.csproj') --nologo -v q
if ($LASTEXITCODE -ne 0) { throw 'tests failed - nothing was built or deployed' }
}
if ($Deploy) {
$target = [IO.Path]::GetFullPath($InstallDir).TrimEnd('\') + '\'
Get-CimInstance Win32_Process -Filter "Name='adolens.exe'" |
Where-Object { $_.ExecutablePath -and $_.ExecutablePath.StartsWith($target, [StringComparison]::OrdinalIgnoreCase) } |
ForEach-Object {
Write-Host " stopping adolens (PID $($_.ProcessId))"
Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue
}
Start-Sleep -Milliseconds 500
$out = Join-Path $InstallDir 'bin'
}
& dotnet build $proj -c $Configuration -o $out --nologo -v q
if ($LASTEXITCODE -ne 0) { throw 'build failed' }
Write-Host "done: $out\adolens.exe" -ForegroundColor Cyan
if ($Deploy) {
Write-Host 'restart Claude Desktop / Claude Code sessions' -ForegroundColor Yellow
}
else {
Write-Host "test: `"$out\adolens.exe`" status" -ForegroundColor Gray
}