microsoft/TypeAgent

Public

mirrored fromhttps://github.com/microsoft/TypeAgentAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
cleanup/test-consolelogs

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

dotnet/agentLauncher/src/Build.ps1

150lines · modecode

1$ErrorActionPreference = "Stop"
2
3$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
4Set-Location $scriptDir
5
6Write-Host "TypeAgent Agent Launcher - Build Script" -ForegroundColor Cyan
7Write-Host "=======================================" -ForegroundColor Cyan
8Write-Host ""
9
10# Configuration
11$projectFile = Join-Path $scriptDir "AgentLauncher.csproj"
12$configuration = "Debug"
13$platform = "x64"
14
15# Calculate paths for uriHandler bundle
16$uriHandlerPath = Join-Path $scriptDir "..\..\..\ts\packages\uriHandler" | Resolve-Path -ErrorAction SilentlyContinue
17$bundleOutput = if ($uriHandlerPath) { Join-Path $uriHandlerPath "bundle\agent-uri-handler.bundle.js" } else { $null }
18$targetDir = Join-Path $scriptDir "Scripts"
19$targetPath = Join-Path $targetDir "agent-uri-handler.bundle.js"
20
21# Find MSBuild
22$msbuildPath2022 = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe";
23$msbuildPath2026 = "C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Current\Bin\MSBuild.exe";
24if (Test-Path $msbuildPath2022) {
25 $msbuildPath = $msbuildPath2022
26} else {
27 $msbuildPath = $msbuildPath2026
28 if (-not (Test-Path $msbuildPath)) {
29 Write-Host "ERROR: MSBuild not found at the following location:" -ForegroundColor Red
30 Write-Host "- $msbuildPath2022" -ForegroundColor Red
31 Write-Host "- $msbuildPath2026" -ForegroundColor Red
32 Write-Host "Please update the path in this script or ensure Visual Studio 2022 is installed." -ForegroundColor Yellow
33 exit 1
34 }
35}
36
37Write-Host "Configuration:" -ForegroundColor Yellow
38Write-Host " Project: $projectFile"
39Write-Host " Configuration: $configuration"
40Write-Host " Platform: $platform"
41Write-Host ""
42
43# Copy bundle from uriHandler
44Write-Host "Step 1: Copying uriHandler bundle..." -ForegroundColor Yellow
45if (-not $bundleOutput -or -not (Test-Path $bundleOutput)) {
46 Write-Host ""
47 Write-Host "ERROR: Bundle file not found at: $bundleOutput" -ForegroundColor Red
48 Write-Host ""
49 Write-Host "You must first build the uriHandler package:" -ForegroundColor Yellow
50 if ($uriHandlerPath) {
51 Write-Host " 1. Navigate to: $uriHandlerPath" -ForegroundColor Cyan
52 } else {
53 Write-Host " 1. Navigate to the uriHandler package directory" -ForegroundColor Cyan
54 }
55 Write-Host " 2. Run: pnpm run build" -ForegroundColor Cyan
56 Write-Host ""
57 exit 1
58}
59
60$bundleSize = (Get-Item $bundleOutput).Length
61$bundleSizeKB = [Math]::Round($bundleSize / 1KB, 2)
62Write-Host " Bundle found: $bundleSizeKB KB at $bundleOutput" -ForegroundColor Green
63
64New-Item -ItemType Directory -Force -Path $targetDir | Out-Null
65Copy-Item $bundleOutput $targetPath -Force
66
67if (Test-Path $targetPath) {
68 Write-Host " Bundle copied successfully to: $targetPath" -ForegroundColor Green
69} else {
70 Write-Host " ERROR: Failed to copy bundle" -ForegroundColor Red
71 exit 1
72}
73Write-Host ""
74
75# Clean previous build
76Write-Host "Step 2: Cleaning previous build..." -ForegroundColor Yellow
77Remove-Item -Recurse -Force obj,bin -ErrorAction SilentlyContinue
78Write-Host " Clean complete" -ForegroundColor Green
79Write-Host ""
80
81# Build
82Write-Host "Step 3: Building project..." -ForegroundColor Yellow
83$buildArgs = @(
84 $projectFile,
85 "-t:Restore,Build",
86 "-p:Configuration=$configuration",
87 "-p:Platform=$platform",
88 "-verbosity:minimal"
89)
90
91& $msbuildPath $buildArgs
92
93if ($LASTEXITCODE -ne 0) {
94 Write-Host ""
95 Write-Host "ERROR: Build failed with exit code $LASTEXITCODE" -ForegroundColor Red
96 exit $LASTEXITCODE
97}
98
99Write-Host " Build complete" -ForegroundColor Green
100Write-Host ""
101
102# Package
103Write-Host "Step 4: Creating MSIX package..." -ForegroundColor Yellow
104$packageArgs = @(
105 $projectFile,
106 "-t:_GenerateAppxPackage",
107 "-p:Configuration=$configuration",
108 "-p:Platform=$platform",
109 "-p:AppxPackageSigningEnabled=false",
110 "-verbosity:minimal"
111)
112
113& $msbuildPath $packageArgs
114
115if ($LASTEXITCODE -ne 0) {
116 Write-Host ""
117 Write-Host "ERROR: Packaging failed with exit code $LASTEXITCODE" -ForegroundColor Red
118 exit $LASTEXITCODE
119}
120
121Write-Host " Build complete" -ForegroundColor Green
122Write-Host ""
123
124# Verify package was created
125$packagePath = "bin\$platform\$configuration\net8.0-windows10.0.26100.0\AppPackages\AgentLauncher_1.0.0.0_x64_Debug_Test\AgentLauncher_1.0.0.0_x64_Debug.msix"
126if (Test-Path $packagePath) {
127 Write-Host "Build successful!" -ForegroundColor Green
128 Write-Host ""
129 Write-Host "Package location:" -ForegroundColor Cyan
130 Write-Host " $packagePath" -ForegroundColor Gray
131 Write-Host ""
132 Write-Host "Next steps:" -ForegroundColor Cyan
133 Write-Host " 1. Sign the package: .\Sign-Package.ps1" -ForegroundColor Gray
134 Write-Host " 2. Install: .\Install.ps1 (requires Administrator)" -ForegroundColor Gray
135} else {
136 Write-Host "WARNING: Build succeeded but package not found at expected location:" -ForegroundColor Yellow
137 Write-Host " $packagePath" -ForegroundColor Gray
138 Write-Host ""
139 Write-Host "Searching for MSIX packages..." -ForegroundColor Yellow
140 $msixFiles = Get-ChildItem -Path "bin" -Recurse -Filter "*.msix" -ErrorAction SilentlyContinue
141 if ($msixFiles) {
142 Write-Host "Found MSIX package(s):" -ForegroundColor Green
143 foreach ($file in $msixFiles) {
144 Write-Host " $($file.FullName)" -ForegroundColor Gray
145 }
146 } else {
147 Write-Host "No MSIX packages found." -ForegroundColor Red
148 exit 1
149 }
150}
151