Repository navigation
Expand file tree
/
Copy pathbootstrap.ps1
More file actions
1007 lines (924 loc) · 50.9 KB
/
Copy pathbootstrap.ps1
File metadata and controls
1007 lines (924 loc) · 50.9 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#requires -Version 5.1
<#
.SYNOPSIS
One-command setup for a Microsoft.UI.Reactor source checkout.
.DESCRIPTION
Builds the `mur` CLI, installs it as a dotnet global tool, packs the
framework packages into local-nupkgs/, installs the Windows
App SDK `dotnet new` template pack (which ships `dotnet new reactor`),
and (optionally) drops the Claude Code plugin under
~/.claude/plugins/reactor.
Idempotent — safe to re-run after `git pull` to refresh everything.
For a less heavyweight refresh (mur stays put), run `mur upgrade`.
.PARAMETER SkipPlugin
Skip installing the Claude Code plugin under ~/.claude/plugins.
.PARAMETER SkipMurInstall
Build and pack the CLI but don't run `dotnet tool install/update`.
Useful for CI or for users who manage tool installs externally.
.PARAMETER SkipVsExtension
Skip building / installing the Reactor Visual Studio embedded-preview
extension (`src/vs-reactor`). Default behavior is to detect VS via
vswhere and install the VSIX into the highest-version instance if
that instance has the 'Visual Studio extension development' workload.
Passing this flag (or not having VS / the workload installed) silently
skips this step — the rest of the bootstrap still completes.
.PARAMETER Configuration
Build configuration for the CLI nupkg. Default: Release.
.PARAMETER InstallWinAppSdk
Install the Windows App Runtime via winget without prompting. The exact
runtime is derived from WindowsAppSDKVersion in Directory.Build.props.
Useful for CI / one-shot dev-box automation. Mutually exclusive with
-NoWinAppSdk. The framework defaults to self-contained, so the
runtime is only required for framework-dependent deployment.
.PARAMETER NoWinAppSdk
Skip the Windows App Runtime prompt silently. Useful for
non-interactive scripts that explicitly don't want the runtime
installed. Mutually exclusive with -InstallWinAppSdk.
.PARAMETER SkipWinAppCli
Skip installing the winapp CLI (`Microsoft.WinAppCli`). The CLI is the
UI automation driver used by the cross-process E2E tests in
`tests/Reactor.AppTests`; bootstrap installs it via winget by default so
those tests can run locally. Pass this flag if you don't run the E2E
suite or manage the CLI yourself. The install is best-effort either way —
a missing winget only warns, it never fails the bootstrap.
.PARAMETER NpmRegistry
Deprecated; ignored. GitHub.Copilot.SDK no longer downloads its native CLI
from npm. Bootstrap warns and continues when this is passed. To redirect the
CLI download, set the CopilotCliReleaseBaseUrl MSBuild property or the
COPILOT_CLI_DOWNLOAD_BASE_URL environment variable, or point
CopilotCliBinaryPath at a pre-downloaded binary.
.PARAMETER NuGetConfig
Use an explicit NuGet.Config for bootstrap restores. When omitted, bootstrap
uses a packagefeedproxy.microsoft.io source already present in the user's
NuGet.Config if it is reachable; otherwise the repo's public config remains
in effect.
.PARAMETER WinAppSdkTemplatesVersion
Pin the Windows App SDK template pack to an explicit version, passed through
to `winapp new --template-version`. By default bootstrap installs the pack
only when it is missing and otherwise keeps what is already installed, so
this is only needed to hold the templates at a known-good version or to force
an update (`latest`).
.PARAMETER SkipTemplates
Skip installing the Windows App SDK `dotnet new` template pack. The rest of
the bootstrap (mur, framework nupkgs, plugin, VS extension) still completes;
you just won't get `dotnet new reactor` from this run.
.PARAMETER Verbose
Common parameter (enabled by [CmdletBinding]). Surfaces extra
diagnostic output at every decision point: detected SDK list,
winget probe exit codes, host arch / pack args, global-tool
install-vs-update branch, template uninstall decision, plugin
symlink-vs-copy fallback, etc. Use this when bootstrap fails or
behaves unexpectedly and you want to see *why* a branch was taken.
.EXAMPLE
./bootstrap.ps1
Full bootstrap (prompts before installing WindowsAppRuntime).
.EXAMPLE
./bootstrap.ps1 -SkipPlugin
Skip the Claude plugin step.
.EXAMPLE
./bootstrap.ps1 -InstallWinAppSdk -SkipPlugin
Non-interactive: install everything (incl. WindowsAppRuntime) and
skip the agent plugin. Suitable for CI / fresh-dev-box automation.
.EXAMPLE
./bootstrap.ps1 -Verbose
Print extra `VERBOSE:` diagnostics at every decision point. Useful
for debugging install failures or unexpected branch behavior.
.EXAMPLE
./bootstrap.ps1 -WinAppSdkTemplatesVersion 0.0.7-alpha
Hold the `dotnet new reactor` template pack at a known-good version
instead of taking whatever `winapp new` installs by default.
#>
[CmdletBinding()]
param(
[switch]$SkipPlugin,
[switch]$SkipMurInstall,
[switch]$SkipVsExtension,
[string]$Configuration = 'Release',
[switch]$InstallWinAppSdk,
[switch]$NoWinAppSdk,
[switch]$SkipWinAppCli,
[string]$NpmRegistry,
[string]$NuGetConfig,
[string]$WinAppSdkTemplatesVersion,
[switch]$SkipTemplates
)
if ($InstallWinAppSdk -and $NoWinAppSdk) {
Write-Host ''
Write-Host "ERROR: -InstallWinAppSdk and -NoWinAppSdk are mutually exclusive." -ForegroundColor Red
exit 1
}
$ErrorActionPreference = 'Stop'
$repoRoot = $PSScriptRoot
Set-Location $repoRoot
$feedResolver = Join-Path $repoRoot 'tools\BootstrapFeedResolver.ps1'
if (-not (Test-Path -LiteralPath $feedResolver -PathType Leaf)) {
Write-Host "ERROR: Missing bootstrap feed resolver: $feedResolver" -ForegroundColor Red
exit 1
}
. $feedResolver
# -Verbose is a common parameter (CmdletBinding); $VerbosePreference flips to
# 'Continue' automatically when the caller passes it. We expose a tiny helper
# so verbose blocks can short-circuit (e.g. skipping expensive `Out-String`
# captures) when the flag is off.
$script:VerboseOn = ($VerbosePreference -ne 'SilentlyContinue')
function Write-Dbg($msg) {
Write-Verbose $msg
}
function Write-Step($msg) {
Write-Host ''
Write-Host "==> $msg" -ForegroundColor Cyan
}
function Write-Ok($msg) {
Write-Host " [ok] $msg" -ForegroundColor Green
}
function Fail($msg) {
Write-Host ''
Write-Host "ERROR: $msg" -ForegroundColor Red
exit 1
}
# Install a winget package and refresh $env:Path so the freshly-installed tool
# is resolvable in this same shell. Hard-fails if winget itself is missing —
# that's an OS-level prerequisite this script doesn't try to repair.
function Install-WithWinget {
param(
[Parameter(Mandatory)][string]$Id,
[string]$Reason = $Id
)
if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
Fail "Need to install '$Reason' but winget is not on PATH. Install App Installer from the Microsoft Store, then re-run ./bootstrap.ps1."
}
Write-Host " Installing $Reason via winget ($Id)..." -ForegroundColor Yellow
Write-Dbg "winget install --id $Id --accept-source-agreements --accept-package-agreements --silent --disable-interactivity"
& winget install --id $Id --accept-source-agreements --accept-package-agreements --silent --disable-interactivity
Write-Dbg "winget exit code: $LASTEXITCODE"
if ($LASTEXITCODE -ne 0 -and $LASTEXITCODE -ne -1978335189) {
# -1978335189 = APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE (already installed / up-to-date)
Fail "winget install $Id failed (exit $LASTEXITCODE). Install $Reason manually and re-run ./bootstrap.ps1."
}
# winget edits the Machine + User PATH but the current process keeps its
# original. Rebuild $env:Path from the registry so subsequent commands in
# this script can find the freshly-installed binaries.
$env:Path = (
[Environment]::GetEnvironmentVariable('Path', 'Machine'),
[Environment]::GetEnvironmentVariable('Path', 'User')
) -join ';'
Write-Dbg "Refreshed `$env:Path from registry (Machine + User scopes)"
}
# ---------------------------------------------------------------------------
# 1. Pre-flight
# ---------------------------------------------------------------------------
Write-Step 'Pre-flight checks'
Write-Dbg "PowerShell $($PSVersionTable.PSVersion); OS arch $env:PROCESSOR_ARCHITECTURE; repo $repoRoot"
function Test-DotnetSdk11 {
if (-not (Get-Command dotnet -ErrorAction SilentlyContinue)) { return $false }
foreach ($line in (& dotnet --list-sdks)) {
Write-Dbg " dotnet SDK: $line"
# global.json pins 11.0.100 with rollForward latestFeature: only a stable 11.0.x
# SDK satisfies it (not an 11 preview, and not 12+, which is a major roll).
if ($line -match '^11\.0\.\d+ \[') { return $true }
}
return $false
}
# Reactor builds with the .NET 11 SDK (C# 15, see global.json) but targets net10.0,
# so running its apps and tests also needs the .NET 10 runtime, which the 11 SDK
# does not carry. The Desktop runtime includes Microsoft.NETCore.App as well as the
# WindowsDesktop.App the WinForms/WPF interop samples need.
function Test-DotnetRuntime10 {
if (-not (Get-Command dotnet -ErrorAction SilentlyContinue)) { return $false }
$core = $false; $desktop = $false
foreach ($line in (& dotnet --list-runtimes)) {
# Stable 10.0.x only: release-built apps don't roll forward onto prerelease runtimes.
if ($line -match '^Microsoft\.NETCore\.App 10\.0\.\d+ \[') { $core = $true }
if ($line -match '^Microsoft\.WindowsDesktop\.App 10\.0\.\d+ \[') { $desktop = $true }
}
return ($core -and $desktop)
}
if (-not (Test-DotnetSdk11)) {
if (-not (Get-Command dotnet -ErrorAction SilentlyContinue)) {
Write-Host " [info] dotnet not found on PATH." -ForegroundColor Yellow
} else {
Write-Host " [info] dotnet present but no .NET 11+ SDK detected. Installed:" -ForegroundColor Yellow
& dotnet --list-sdks | ForEach-Object { Write-Host " $_" -ForegroundColor Yellow }
}
Install-WithWinget -Id 'Microsoft.DotNet.SDK.11' -Reason '.NET 11 SDK'
if (-not (Test-DotnetSdk11)) {
Fail '.NET 11 SDK install reported success but `dotnet --list-sdks` still does not show an 11.x entry. Open a new shell and re-run ./bootstrap.ps1.'
}
}
Write-Ok ".NET SDK present"
if (-not (Test-DotnetRuntime10)) {
Install-WithWinget -Id 'Microsoft.DotNet.DesktopRuntime.10' -Reason '.NET 10 Desktop runtime (Reactor targets net10.0)'
if (-not (Test-DotnetRuntime10)) {
Fail '.NET 10 Desktop runtime install reported success but `dotnet --list-runtimes` still does not show Microsoft.NETCore.App 10.x and Microsoft.WindowsDesktop.App 10.x. Open a new shell and re-run ./bootstrap.ps1.'
}
}
Write-Ok ".NET 10 runtime present"
$hostArch = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'ARM64' } else { 'x64' }
if ($PSBoundParameters.ContainsKey('NpmRegistry')) {
Write-Host " [warn] -NpmRegistry is deprecated and ignored: GitHub.Copilot.SDK now downloads its native CLI from GitHub releases, not npm. To redirect it, set CopilotCliReleaseBaseUrl or COPILOT_CLI_DOWNLOAD_BASE_URL, or point CopilotCliBinaryPath at a pre-downloaded binary." -ForegroundColor Yellow
}
$nugetSelection = Resolve-ReactorNuGetFeed -ExplicitConfig $NuGetConfig
if ($nugetSelection -and -not $nugetSelection.Explicit) {
Write-Dbg "Testing NuGet source access: $($nugetSelection.Source)"
if (-not (Test-ReactorNuGetSourceAccess -Source $nugetSelection.Source)) {
Write-Host " [warn] Configured NuGet proxy cannot provide GitHub.Copilot.SDK; falling back to the repo's public NuGet config." -ForegroundColor Yellow
$nugetSelection = $null
}
}
$effectiveNuGetConfig = if ($nugetSelection -and $nugetSelection.Explicit) { $nugetSelection.ConfigPath } else { $null }
$effectiveNuGetSource = if ($nugetSelection -and -not $nugetSelection.Explicit) { $nugetSelection.Source } else { $null }
if ($nugetSelection) {
if ($nugetSelection.Explicit) {
Write-Ok "NuGet config selected by explicit override: $effectiveNuGetConfig"
} else {
Write-Ok "NuGet proxy selected from user configuration: $effectiveNuGetSource"
}
} else {
Write-Dbg 'No reachable configured NuGet proxy detected; using the repo nuget.config'
}
function Get-VsExtensionSkipReason {
param([Parameter(Mandatory)]$VsInstance)
# The VSIX manifest targets [18.0,19.0): the extension supports Visual Studio 2026 only.
$vsVersion = [string]$VsInstance.installationVersion
if ($vsVersion -notmatch '^(\d+)\.') { return $null }
$vsMajor = [int]$Matches[1]
if ($vsMajor -ge 18) { return $null }
return "The Reactor Preview extension supports Visual Studio 2026 (18.0+) only, but the newest instance with the 'Visual Studio extension development' workload is $vsVersion."
}
# Windows App SDK runtime — recommended for samples, perf-tests, and any
# project that omits WindowsAppSDKSelfContained=true.
#
# The repo defaults WindowsAppSDKSelfContained=false (see
# Directory.Build.props) so samples and perf benches share a single
# machine-wide Microsoft.WindowsAppRuntime install rather than bundling a
# copy of the runtime into every build output. The AOT-publish trim
# proofs (tests/aot_trim_proof/*) keep =true explicitly so their build
# output stays a standalone deployable.
#
# Net effect: the user needs the machine-wide Windows App Runtime matching our
# WindowsAppSDKVersion to run most things in this repo. (Framework-dependent
# projects reference the Microsoft.WindowsAppSDK.WinUI sub-package rather than
# the full metapackage, but still bind that same machine-wide runtime.)
#
# So we prompt by default. `-InstallWinAppSdk` to force-install,
# `-InstallWinAppSdk:$false` to skip the prompt non-interactively.
#
# The runtime identity and the version comparison live in
# tools/WindowsAppRuntimeId.ps1 -- see that file for why the 2.x winget id is
# major-only and why its presence alone does not prove the runtime is new
# enough. bootstrap.yml and WinAppSDKReferenceGuardTests.cs load the same file.
$winAppRuntimeLib = Join-Path $repoRoot 'tools\WindowsAppRuntimeId.ps1'
if (-not (Test-Path -LiteralPath $winAppRuntimeLib -PathType Leaf)) {
Write-Host "ERROR: Missing Windows App Runtime helper: $winAppRuntimeLib" -ForegroundColor Red
exit 1
}
. $winAppRuntimeLib
$winAppSdkVersion = Get-PinnedWindowsAppSdkVersion -PropsPath (Join-Path $repoRoot 'Directory.Build.props')
$winAppRuntimeId = Get-WindowsAppRuntimeWingetId $winAppSdkVersion
if (-not $winAppRuntimeId) {
# Guessing an id here risks installing a runtime that cannot load what this
# checkout builds, which is worse than saying nothing. Loud rather than
# silent when the caller explicitly asked for the install.
$msg = "Could not read WindowsAppSDKVersion from Directory.Build.props, so the Windows App Runtime could not be identified."
if ($InstallWinAppSdk) {
Fail "$msg -InstallWinAppSdk cannot be honored."
}
Write-Host " [warn] $msg Skipping the runtime check." -ForegroundColor Yellow
} else {
$winAppRuntimeLabel = "Windows App Runtime (for Windows App SDK $winAppSdkVersion)"
Write-Dbg "Windows App Runtime winget id derived from WindowsAppSDKVersion=$($winAppSdkVersion): $winAppRuntimeId"
# Returns 'satisfied' | 'outdated' | 'missing' | 'unreadable' | 'nowinget'.
#
# 'outdated' is a real state, not a theoretical one: the 2.x id is
# major-wide, so a machine carrying 2.0.1 reports the package as installed
# even though it cannot load an app built against 2.2.0. Treating presence
# as sufficient would print [ok] over exactly the mismatch this check exists
# to catch.
#
# 'nowinget' and 'unreadable' are kept apart because the remedy differs:
# one needs App Installer before any winget advice is actionable, the other
# already has winget and just needs the install run.
function Get-WindowsAppRuntimeState {
param(
[Parameter(Mandatory)][string]$Id,
[Parameter(Mandatory)][string]$RequiredSdkVersion
)
if (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
Write-Dbg "winget not on PATH; cannot probe WindowsAppRuntime"
return 'nowinget'
}
# --accept-source-agreements is needed even for `list` on a winget that
# hasn't been used before (e.g. a fresh CI runner). Without it, winget
# prompts for msstore terms and fails on a non-interactive shell with
# exit -1978335166.
Write-Dbg "winget list --id $Id --exact --accept-source-agreements"
$output = & winget list --id $Id --exact --accept-source-agreements 2>$null | Out-String
$rc = $LASTEXITCODE
Write-Dbg "winget list exit code: $rc"
$global:LASTEXITCODE = 0 # don't let winget's status leak out of the probe
if ($script:VerboseOn) {
$output -split "`r?`n" | ForEach-Object { if ($_) { Write-Dbg " winget> $_" } }
}
if ($rc -ne 0) { return 'missing' }
$installed = Get-WindowsAppRuntimeVersionFromWingetOutput -Output $output
if ($null -eq $installed) {
# Present, but the version column could not be read. Do not claim it
# is too old on the strength of a parse failure.
Write-Dbg "winget reported $Id installed but no version could be parsed"
return 'unreadable'
}
Write-Dbg "installed $Id version: $installed (need >= $RequiredSdkVersion)"
if (Test-WindowsAppRuntimeSatisfied -Installed $installed -RequiredSdkVersion $RequiredSdkVersion) {
return 'satisfied'
}
return 'outdated'
}
$winAppRuntimeState = Get-WindowsAppRuntimeState -Id $winAppRuntimeId -RequiredSdkVersion $winAppSdkVersion
$winAppRuntimeUnverified = @('unreadable', 'nowinget') -contains $winAppRuntimeState
if ($winAppRuntimeState -eq 'satisfied') {
Write-Ok "$winAppRuntimeLabel installed"
} elseif ($winAppRuntimeUnverified -and -not $InstallWinAppSdk) {
# Not proven missing, so do not nag an interactive user or fail -NoWinAppSdk.
# -InstallWinAppSdk is handled below instead: an explicit force-install must
# not become a no-op just because the probe could not read winget's output.
if ($winAppRuntimeState -eq 'nowinget') {
Write-Host " [warn] Could not verify $winAppRuntimeLabel - winget is not on PATH." -ForegroundColor Yellow
Write-Host " Install App Installer from the Microsoft Store, then re-run ./bootstrap.ps1."
Write-Host " Or install the runtime by hand: https://learn.microsoft.com/windows/apps/windows-app-sdk/downloads"
} else {
Write-Host " [warn] Could not verify $winAppRuntimeLabel - winget's output could not be read." -ForegroundColor Yellow
Write-Host " If samples fail to launch, install it with: winget install $winAppRuntimeId"
}
} else {
$problem = switch ($winAppRuntimeState) {
'outdated' { "$winAppRuntimeLabel is installed but too old for Windows App SDK $winAppSdkVersion." }
'unreadable' { "$winAppRuntimeLabel could not be verified." }
'nowinget' { "$winAppRuntimeLabel could not be verified (winget is not on PATH)." }
default { "$winAppRuntimeLabel is not installed on this machine." }
}
if ($InstallWinAppSdk) {
# winget exits 'no applicable update' when the runtime is already current,
# which Install-WithWinget already treats as success -- so installing on an
# unverifiable state is safe, and safer than skipping.
Install-WithWinget -Id $winAppRuntimeId -Reason $winAppRuntimeLabel
} elseif ($NoWinAppSdk) {
Write-Host " [skip] $problem (skipped per -NoWinAppSdk)." -ForegroundColor Yellow
} else {
Write-Host ''
Write-Host " $problem" -ForegroundColor Yellow
Write-Host ' The Reactor repo defaults to WindowsAppSDKSelfContained=false, so most'
Write-Host ' samples, perf benches, and apps in this repo need the machine-wide runtime'
Write-Host ' installed to launch. Skip only if you know your projects override'
Write-Host ' WindowsAppSDKSelfContained=true to bundle their own copy.'
$answer = Read-Host " Install $winAppRuntimeId via winget now? [y/N]"
if ($answer -match '^[Yy]') {
Install-WithWinget -Id $winAppRuntimeId -Reason $winAppRuntimeLabel
} else {
Write-Host " Skipped. Re-run later with: winget install $winAppRuntimeId" -ForegroundColor Cyan
}
}
}
}
# ---------------------------------------------------------------------------
# 1.6 winapp CLI (E2E UI test driver)
# ---------------------------------------------------------------------------
# The cross-process E2E tests in tests/Reactor.AppTests drive the running app
# through the `winapp ui` CLI (Microsoft.WinAppCli) instead of WinAppDriver.
# WinAppUi.ResolveWinAppExe() resolves it from %LOCALAPPDATA%\Microsoft\
# WindowsApps\winapp.exe (the alias winget's MSIX install drops) or `winapp`
# on PATH. Install it best-effort so `dotnet test tests/Reactor.AppTests`
# works out of the box — a missing winget only warns, it never fails bootstrap.
Write-Step 'Checking winapp CLI (E2E UI test driver)'
function Get-WinAppCliPath {
<#
.SYNOPSIS
Path to the winapp CLI, or $null when it isn't installed.
.DESCRIPTION
Prefers PATH, then the app-execution alias winget's MSIX install drops.
Callers must invoke *this* result rather than a bare `winapp`: the alias
exists on disk without necessarily being resolvable through the current
process's PATH, which is the whole reason the fallback exists.
#>
$onPath = Get-Command winapp -ErrorAction SilentlyContinue
if ($onPath) { return $onPath.Source }
$alias = Join-Path $env:LOCALAPPDATA 'Microsoft\WindowsApps\winapp.exe'
Write-Dbg "winapp not on PATH; probing alias $alias"
if (Test-Path $alias) { return $alias }
return $null
}
function Test-WinAppCli {
return $null -ne (Get-WinAppCliPath)
}
if ($SkipWinAppCli) {
Write-Host ' [skip] winapp CLI install skipped (per -SkipWinAppCli).' -ForegroundColor Yellow
} elseif (Test-WinAppCli) {
Write-Ok 'winapp CLI present'
} elseif (-not (Get-Command winget -ErrorAction SilentlyContinue)) {
Write-Host ' [warn] winapp CLI not found and winget is unavailable to install it.' -ForegroundColor Yellow
Write-Host ' E2E tests (tests/Reactor.AppTests) need it. Install manually with:' -ForegroundColor Yellow
Write-Host ' winget install Microsoft.WinAppCli (or grab winappcli-x64.zip from the WinAppCli releases)' -ForegroundColor Cyan
} else {
Write-Host ' Installing winapp CLI via winget (Microsoft.WinAppCli)...' -ForegroundColor Yellow
Write-Dbg 'winget install --id Microsoft.WinAppCli --accept-source-agreements --accept-package-agreements --silent --disable-interactivity'
& winget install --id Microsoft.WinAppCli --accept-source-agreements --accept-package-agreements --silent --disable-interactivity
$rc = $LASTEXITCODE
Write-Dbg "winget exit code: $rc"
$global:LASTEXITCODE = 0
# -1978335189 = already installed / up-to-date.
if ($rc -ne 0 -and $rc -ne -1978335189) {
Write-Host " [warn] winget install Microsoft.WinAppCli reported exit $rc. Install it manually to run the E2E suite." -ForegroundColor Yellow
} else {
# winget edits Machine + User PATH but not the live process; rebuild it
# so a follow-on E2E run in this same shell can resolve winapp.
$env:Path = (
[Environment]::GetEnvironmentVariable('Path', 'Machine'),
[Environment]::GetEnvironmentVariable('Path', 'User')
) -join ';'
if (Test-WinAppCli) {
Write-Ok 'winapp CLI installed'
} else {
Write-Host ' [warn] winapp CLI install reported success but the binary is not yet resolvable.' -ForegroundColor Yellow
Write-Host ' Open a new shell before running the E2E suite.' -ForegroundColor Cyan
}
}
}
# ---------------------------------------------------------------------------
# 2. Pack `mur` as a global-tool nupkg
# ---------------------------------------------------------------------------
Write-Step "Packing mur (Reactor CLI) for dotnet global tool install"
$feed = Join-Path $repoRoot 'local-nupkgs'
New-Item -ItemType Directory -Path $feed -Force | Out-Null
Write-Dbg "Local nupkg feed: $feed"
# Match host arch so the embed-resource step (which runs the SignaturesGen
# apphost) succeeds. The packed IL itself is platform-portable.
Write-Dbg "Host arch resolved to: $hostArch"
# Stamp a unique, monotonically-increasing local version. Get-ReactorLocalCliVersion
# (tools/BootstrapFeedResolver.ps1) documents why the encoding looks the way it
# does; it lives there rather than inline so its shape, bounds, and ordering are
# covered by tests/vs_reactor/ci/BootstrapFeedResolver.Tests.ps1.
$cliLocalVersion = Get-ReactorLocalCliVersion
Write-Dbg "Local mur version stamp: $cliLocalVersion"
$cliPackArgs = @(
'pack',
(Join-Path $repoRoot 'src\Reactor.Cli\Reactor.Cli.csproj'),
'-c', $Configuration,
"-p:Platform=$hostArch",
"-p:Version=$cliLocalVersion",
'-o', $feed,
'--nologo', '-v:m'
)
$cliPackArgs += Get-ReactorRestoreArguments `
-NuGetConfig $effectiveNuGetConfig `
-NuGetSource $effectiveNuGetSource
Write-Dbg "dotnet $($cliPackArgs -join ' ')"
$cliPackExit = 0
Invoke-ReactorWithRestoreEnvironment `
-NuGetConfig $effectiveNuGetConfig `
-NuGetSource $effectiveNuGetSource `
-ExitCode ([ref]$cliPackExit) `
-Action {
& dotnet @cliPackArgs
}
if ($cliPackExit -ne 0) { Fail 'dotnet pack failed for Reactor.Cli' }
Write-Ok "Packed Microsoft.UI.Reactor.Cli -> $feed"
# ---------------------------------------------------------------------------
# 3. Install / update the global tool
# ---------------------------------------------------------------------------
if ($SkipMurInstall) {
Write-Host ''
Write-Host ' Skipping `dotnet tool install` (per -SkipMurInstall).' -ForegroundColor Yellow
} else {
Write-Step 'Installing mur as a dotnet global tool'
$existing = & dotnet tool list -g 2>$null | Select-String -SimpleMatch 'microsoft.ui.reactor.cli'
$toolArgs = Get-ReactorToolArguments `
-Feed $feed `
-NuGetConfig $effectiveNuGetConfig `
-NuGetSource $effectiveNuGetSource `
-Version $cliLocalVersion
if ($existing) {
Write-Dbg "Existing global tool detected ($($existing.Line.Trim())); using 'dotnet tool update'"
& dotnet tool update @toolArgs
} else {
Write-Dbg "No existing global tool; using 'dotnet tool install'"
& dotnet tool install @toolArgs
}
if ($LASTEXITCODE -ne 0) { Fail '`dotnet tool install/update` failed for Microsoft.UI.Reactor.Cli' }
# Make ~/.dotnet/tools visible to the rest of this script even if this is
# the first global tool the user has ever installed (dotnet adds it to the
# User PATH but not the current process).
$dotnetTools = Join-Path $env:USERPROFILE '.dotnet\tools'
if (Test-Path $dotnetTools) {
$pathParts = $env:Path -split ';'
if ($pathParts -notcontains $dotnetTools) {
Write-Dbg "Prepending $dotnetTools to current-process PATH"
$env:Path = "$dotnetTools;$env:Path"
} else {
Write-Dbg "$dotnetTools already on current-process PATH"
}
}
# Prove the binary on PATH is the one we just built.
#
# The exit-code check above cannot detect a stale tool: a no-op `dotnet
# tool update` exits 0. That is exactly how installs drifted months behind
# HEAD while every bootstrap run reported success. The SDK appends the
# source revision to AssemblyInformationalVersion, so `mur --version`
# prints `mur <ver>+<40-hex-sha>` — compare that against HEAD.
#
# git is resolved via Get-Command rather than invoked speculatively: under
# $ErrorActionPreference = 'Stop' a missing executable raises a terminating
# CommandNotFoundException, so `& git ...` would abort bootstrap instead of
# reaching the non-fatal warning below.
$expectedSha = $null
if (Get-Command git -ErrorAction SilentlyContinue) {
$expectedSha = & git -C $repoRoot rev-parse HEAD 2>$null
if ($LASTEXITCODE -ne 0) { $expectedSha = $null }
}
# Collect the output fully before inspecting it. Piping a native command
# straight into `Select-Object -First 1` closes the pipeline early, which
# can surface as a broken pipe and leaves $LASTEXITCODE non-deterministic —
# so the exit code is captured from the unpiped call.
$murOutput = & mur --version 2>$null
$murExit = $LASTEXITCODE
$murVersionLine = @($murOutput) | Select-Object -First 1
# A `mur` that runs but fails is a broken install, not an unverifiable one.
# Falling through to the warning below would mask exactly the class of
# defect this block exists to catch.
if ($murExit -ne 0) {
Fail ("The installed ``mur`` failed to run (``mur --version`` exited $murExit). " +
"The global tool is present but broken. Run: dotnet tool uninstall -g Microsoft.UI.Reactor.Cli, then re-run ./bootstrap.ps1.")
}
if ($expectedSha -and $murVersionLine -match '\+([0-9a-fA-F]{40})') {
$installedSha = $Matches[1]
if ($installedSha -ne $expectedSha) {
Fail ("Installed mur reports revision $($installedSha.Substring(0,8)) but HEAD is $($expectedSha.Substring(0,8)). " +
"The global tool was not replaced. Run: dotnet tool uninstall -g Microsoft.UI.Reactor.Cli, then re-run ./bootstrap.ps1.")
}
Write-Ok "mur verified at revision $($expectedSha.Substring(0,8)) (version $cliLocalVersion)"
} else {
# Non-fatal: a shallow/exported tree has no git, and a consumer build
# may strip the revision suffix. Say so rather than implying success.
Write-Host " [warn] Could not verify the installed mur revision (mur --version returned '$murVersionLine')." -ForegroundColor Yellow
}
Write-Ok "mur installed as global tool (also on this shell's PATH)"
}
# ---------------------------------------------------------------------------
# 4. Pack the in-source framework packages via the freshly-installed mur
# ---------------------------------------------------------------------------
Write-Step 'Packing local Microsoft.UI.Reactor packages (`mur pack-local`)'
# Use the freshly-installed `mur` if available; otherwise call the source
# project directly (works for -SkipMurInstall too).
#
# Produces the source-built 0.0.0-local framework, Advanced and Devtools nupkgs
# so recipes, samples and scaffolded apps in this clone can resolve the working
# tree instead of the published package.
$packLocalExit = 0
Invoke-ReactorWithRestoreEnvironment `
-NuGetConfig $effectiveNuGetConfig `
-NuGetSource $effectiveNuGetSource `
-ExitCode ([ref]$packLocalExit) `
-Action {
$murResolved = Get-Command mur -ErrorAction SilentlyContinue
if ($murResolved) {
Write-Dbg "Using installed mur at $($murResolved.Source)"
& mur pack-local
} else {
Write-Dbg "mur not on PATH; falling back to 'dotnet run' against Reactor.Cli source"
$murRestoreArgs = Get-ReactorRestoreArguments `
-NuGetConfig $effectiveNuGetConfig `
-NuGetSource $effectiveNuGetSource
& dotnet run `
--project (Join-Path $repoRoot 'src\Reactor.Cli\Reactor.Cli.csproj') `
-c $Configuration `
"-p:Platform=$hostArch" `
--nologo `
@murRestoreArgs `
-- pack-local
}
}
if ($packLocalExit -ne 0) { Fail 'mur pack-local failed' }
# ---------------------------------------------------------------------------
# 5. Install the Windows App SDK `dotnet new` templates (ships `reactor`)
# ---------------------------------------------------------------------------
# Reactor's app templates ship inside the Windows App SDK template pack
# (`Microsoft.WindowsAppSDK.WinUI.CSharp.Templates`), next to the WinUI 3 XAML
# ones. That pack owns the `reactor`, `reactor-mvu`, `reactor-navview`,
# `reactor-tabview` and (from 0.0.8-alpha) `reactor-singlefile` short names, and
# the apps it scaffolds are **packaged** (single-project MSIX) by default — so
# `dotnet run` launches them with package identity, equivalent to F5 in Visual
# Studio.
#
# This repo used to ship its own `Microsoft.UI.Reactor.ProjectTemplates` pack
# (`dotnet new reactorapp`, unpackaged). It was removed once the Windows App SDK
# pack shipped the Reactor templates; the published versions are deprecated on
# NuGet.org with a pointer here. For an unpackaged app, scaffold with
# `dotnet new reactor --packaging Unpackaged` (see docs/guide/packaging.md).
#
# Hoisted so the closing "Next:" guidance can gate on it: printing
# `dotnet new reactor` after verification failed would hand the user the exact
# command bootstrap just proved unavailable.
$templatesVerified = $false
if ($SkipTemplates) {
Write-Host ''
Write-Host ' Skipping `dotnet new` template install (per -SkipTemplates).' -ForegroundColor Yellow
} else {
Write-Step 'Installing Windows App SDK `dotnet new` templates (`dotnet new reactor`)'
$wasdkTemplatePackageId = 'Microsoft.WindowsAppSDK.WinUI.CSharp.Templates'
# Delegate to the Windows App SDK CLI, which owns this pack.
#
# `winapp new --list` installs the pack on demand and prints the templates;
# with --use-defaults it never prompts and keeps an already-installed pack,
# which is exactly bootstrap's "self-healing install-if-missing, not a
# reinstall" semantics. Reactor used to carry its own installer for this
# because `dotnet new install` has no --prerelease switch and resolves
# stable-only (so it fails outright while the pack is prerelease-only), and
# working around that meant version-resolving off the NuGet flat container
# and tiptoeing around `dotnet new install --force`, which uninstalls before
# it downloads. winapp handles all of it.
$winAppNewArgs = @('new', '--list', '--use-defaults')
if ($WinAppSdkTemplatesVersion) {
Write-Dbg "Template version pin: $WinAppSdkTemplatesVersion"
$winAppNewArgs += @('--template-version', $WinAppSdkTemplatesVersion)
}
$templatesExit = 0
$winAppExe = Get-WinAppCliPath
if (-not $winAppExe) {
# winapp is installed in step 4; it can legitimately be absent when that
# step was skipped or winget is unavailable. Don't fail the whole
# bootstrap over it — say what to run and let the verification below
# report the real state.
Write-Host ' [warn] winapp CLI not available, so the template pack cannot be installed here.' -ForegroundColor Yellow
Write-Host ' Install it and re-run, or install the pack directly:'
Write-Host ' winget install Microsoft.WinAppCli'
Write-Host ' winapp new --list'
$templatesExit = 2
} else {
# Invoke the resolved path, not a bare `winapp`: Get-WinAppCliPath also
# accepts the app-execution alias, which exists on disk without always
# being resolvable through this process's PATH.
Write-Dbg "$winAppExe $($winAppNewArgs -join ' ')"
& $winAppExe @winAppNewArgs | Out-Null
$templatesExit = $LASTEXITCODE
}
# Exit 2 is bootstrap's own "winapp unavailable" marker above. Treat it the
# same way as an installed-but-unusable pack: not an install failure, because
# the verification below reports the real state and the closing guidance
# adapts. Collapsing it into this Fail would make both of those unreachable.
if ($templatesExit -ne 0 -and $templatesExit -ne 2) {
Fail (@(
"Installing $wasdkTemplatePackageId failed.",
" The Reactor templates ship in the Windows App SDK template pack,",
" installed here via the Windows App SDK CLI (``winapp new --list``).",
" - To pin a specific pack version:",
" ./bootstrap.ps1 -WinAppSdkTemplatesVersion <version>",
" - To skip this step entirely: ./bootstrap.ps1 -SkipTemplates"
) -join [Environment]::NewLine)
}
# `winapp new --list --use-defaults` deliberately keeps an already-installed
# pack rather than updating it, and that pack can predate the Reactor
# templates (0.0.6-alpha shipped without them), so confirm the short name
# actually resolves before claiming success.
#
# Reuse the CLI probe rather than grepping the listing here: `mur templates
# status` matches the short name as a whole token, which a naive regex does
# not — `\breactor\b` also matches `reactor-mvu` and `winui-reactor`, so a
# listing without the blank template would read as success.
$statusExit = 0
Invoke-ReactorWithRestoreEnvironment `
-NuGetConfig $effectiveNuGetConfig `
-NuGetSource $effectiveNuGetSource `
-ExitCode ([ref]$statusExit) `
-Action {
$murResolved = Get-Command mur -ErrorAction SilentlyContinue
if ($murResolved) { & mur templates status | Out-Null }
else {
& dotnet run `
--project (Join-Path $repoRoot 'src\Reactor.Cli\Reactor.Cli.csproj') `
-c $Configuration "-p:Platform=$hostArch" --nologo `
-- templates status | Out-Null
}
}
$templatesVerified = ($statusExit -eq 0)
if ($templatesVerified) {
Write-Ok '`dotnet new reactor` templates registered'
} else {
# `mur templates status` reports three distinct not-usable situations
# (see TemplatesCommand.StatusExit). They need different advice: telling
# someone their pack "predates the Reactor templates" when it is not
# installed at all — or when the probe itself failed — sends them to
# re-pin a version that was never the problem.
Write-Host ''
switch ($statusExit) {
2 {
Write-Host " [warn] $wasdkTemplatePackageId is installed but does not provide ``dotnet new reactor``." -ForegroundColor Yellow
Write-Host " That version predates the Reactor templates. Update the pack:"
Write-Host " winapp new --list --template-version latest"
}
3 {
Write-Host " [warn] $wasdkTemplatePackageId is not installed, so ``dotnet new reactor`` is unavailable." -ForegroundColor Yellow
Write-Host " Re-run with network access, or install the pack directly:"
Write-Host " winapp new --list"
}
default {
Write-Host " [warn] Could not enumerate ``dotnet new`` templates, so ``dotnet new reactor`` is unverified." -ForegroundColor Yellow
Write-Host " This is a probe failure, not a known-bad install. Check with:"
Write-Host " mur templates status"
}
}
}
}
# ---------------------------------------------------------------------------
# 6. Claude Code plugin (optional)
# ---------------------------------------------------------------------------
if ($SkipPlugin) {
Write-Host ''
Write-Host ' Skipping Claude plugin install (per -SkipPlugin).' -ForegroundColor Yellow
} else {
Write-Step 'Installing Reactor plugin for Claude Code'
$pluginSrc = Join-Path $repoRoot 'plugins\reactor'
$pluginDst = Join-Path $env:USERPROFILE '.claude\plugins\reactor'
Write-Dbg "Plugin src: $pluginSrc"
Write-Dbg "Plugin dst: $pluginDst"
if (-not (Test-Path $pluginSrc)) {
Write-Host " [skip] $pluginSrc not present in this checkout" -ForegroundColor Yellow
} else {
New-Item -ItemType Directory -Path (Split-Path $pluginDst) -Force | Out-Null
if (Test-Path $pluginDst) {
Write-Dbg "Removing existing $pluginDst before re-linking"
Remove-Item $pluginDst -Recurse -Force
}
# Prefer symlink so plugin edits in the checkout are immediately visible.
# Falls back to copy when symlink creation is unprivileged (Developer
# Mode off + non-admin shell).
$linked = $false
try {
New-Item -ItemType SymbolicLink -Path $pluginDst -Target $pluginSrc -ErrorAction Stop | Out-Null
$linked = $true
} catch {
Write-Dbg "Symlink failed: $($_.Exception.Message); falling back to copy"
}
if ($linked) {
Write-Ok "Symlinked $pluginDst -> $pluginSrc"
} else {
Copy-Item $pluginSrc $pluginDst -Recurse -Force
Write-Ok "Copied $pluginSrc -> $pluginDst (re-run bootstrap or `mur upgrade` to refresh)"
}
}
}
# ---------------------------------------------------------------------------
# 7. Reactor Visual Studio embedded-preview extension (optional)
# ---------------------------------------------------------------------------
# Spec 056: ships a VSIX that hosts the live Reactor preview inside a VS tool
# window. Building the VSIX needs the 'Visual Studio extension development'
# workload (desktop MSBuild + VSSDK targets). We probe via vswhere and skip
# silently when VS is absent or the workload isn't installed — the rest of
# the bootstrap (mur, framework nupkgs, template, plugin) doesn't depend on
# the extension, so this step never blocks the install.
if ($SkipVsExtension) {
Write-Host ''
Write-Host ' Skipping VS extension install (per -SkipVsExtension).' -ForegroundColor Yellow
} else {
Write-Step 'Building + installing Reactor Visual Studio extension (VSIX)'
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
if (-not (Test-Path -LiteralPath $vswhere)) {
Write-Host ' [skip] vswhere.exe not found - Visual Studio is not installed. The framework + mur + template + plugin are still ready.' -ForegroundColor Yellow
Write-Host " To install the preview extension later, install Visual Studio 2026 with the 'Visual Studio extension development' workload, then re-run ./bootstrap.ps1."
} else {
# `-requires Microsoft.VisualStudio.Workload.VisualStudioExtension` filters to
# instances that have the VSIX-development workload (desktop MSBuild + VSSDK
# targets). Without it, Build-Vsix.ps1 fails with "Desktop MSBuild was not
# found." or VSSDK target errors. We want to detect the absence here and emit
# a friendly skip note instead of a stack of red MSBuild errors.
Write-Dbg "Probing vswhere for VS instances with the VSIX-dev workload"
$instancesJson = & $vswhere -all -prerelease `
-requires 'Microsoft.VisualStudio.Workload.VisualStudioExtension' `
-format json 2>$null
$instances = if ($instancesJson) { $instancesJson | ConvertFrom-Json } else { @() }
if (-not $instances -or $instances.Count -eq 0) {
Write-Host " [skip] Visual Studio is installed but no instance has the 'Visual Studio extension development' workload." -ForegroundColor Yellow
Write-Host " Add it from the Visual Studio Installer (Modify -> Workloads) and re-run ./bootstrap.ps1."
} else {
$target = $instances | Sort-Object installationVersion -Descending | Select-Object -First 1
Write-Dbg "Target VS: $($target.displayName) ($($target.instanceId), $($target.installationVersion))"
$reinstall = Join-Path $repoRoot 'src\vs-reactor\Reinstall-Vsix.ps1'
if (-not (Test-Path -LiteralPath $reinstall)) {
Write-Host " [skip] $reinstall not present in this checkout (older branch?). Pull `main` to get the VS extension." -ForegroundColor Yellow
} else {
$skipReason = Get-VsExtensionSkipReason $target
if ($skipReason) {
Write-Host " [skip] $skipReason" -ForegroundColor Yellow
Write-Host " Install Visual Studio 2026 with that workload to build and install the optional Reactor Preview VSIX from bootstrap."
} else {
# Reinstall-Vsix.ps1 chains Build-Vsix.ps1 (desktop MSBuild build) then
# the VSIXInstaller against the per-user data dir, plus a synchronous
# `devenv /updateconfiguration` to merge the pkgdef so menus appear on
# the next launch. -VsInstanceId pins to the same instance we probed.
# The feed resolved above has to be forwarded explicitly. This step
# runs in a child process, so it never sees the restore environment
# the rest of the bootstrap sets up for its own commands, and would
# otherwise fall through to the repo's public nuget.config -- which
# not every network can reach.
$vsixFeedArgs = @()
if ($effectiveNuGetConfig) {
$vsixFeedArgs = @('-NuGetConfig', $effectiveNuGetConfig)
} elseif ($effectiveNuGetSource) {
$vsixFeedArgs = @('-NuGetSource', $effectiveNuGetSource)
}
$powerShellExe = (Get-Process -Id $PID).Path
& $powerShellExe -NoLogo -NoProfile -ExecutionPolicy Bypass -File $reinstall -Configuration $Configuration -VsInstanceId $target.instanceId @vsixFeedArgs
$vsixExit = $LASTEXITCODE
# Reinstall-Vsix.ps1's exit-code contract (see its .OUTPUTS):
# 3 == VSIX installed but `devenv /updateconfiguration`
# timed out. Don't claim [ok] for that, and don't fail
# either — the extension is installed and usable.
if ($vsixExit -eq 3) {
Write-Host ''
Write-Host " [warn] VS extension installed into $($target.displayName), but 'devenv /updateconfiguration' did not complete. Launch VS once to finish the menu merge; if View -> Other Windows -> Reactor Preview is missing, re-run src\vs-reactor\Reinstall-Vsix.ps1." -ForegroundColor Yellow
} elseif ($vsixExit -ne 0) {
# Don't fail the whole bootstrap — the rest of the install is
# usable without the VS extension. Surface the failure clearly
# so users debugging install issues see it.
Write-Host ''
Write-Host " [warn] VS extension install reported a non-zero exit code ($vsixExit). The rest of the bootstrap completed; re-run src\vs-reactor\Reinstall-Vsix.ps1 directly to retry." -ForegroundColor Yellow
Write-Host " If the log shows NU1301 against nuget.org, the restore had no reachable feed: re-run with -NuGetSource <url> or -NuGetConfig <path>." -ForegroundColor Yellow
} else {
Write-Ok "VS extension installed into $($target.displayName) - launch VS, then View -> Other Windows -> Reactor Preview."
}
# Write-Host does NOT clear $LASTEXITCODE, so without this
# the child's non-zero code survives to the end of the
# script and fails callers that check it (issue #1074:
# bootstrap.yml's `if ($LASTEXITCODE -ne 0) { throw }`).
$global:LASTEXITCODE = 0
}
}
}
}
}
# ---------------------------------------------------------------------------
# Done
# ---------------------------------------------------------------------------
Write-Host ''
Write-Host 'Bootstrap complete.' -ForegroundColor Green
Write-Host ''
Write-Host 'Next:'
if ($SkipTemplates) {
# Advertising `dotnet new reactor` here would be a false promise: this run
# deliberately did not install the pack, so the command may not resolve.
Write-Host ' Template install was skipped (-SkipTemplates).'
Write-Host ' To scaffold an app, let the Windows App SDK CLI install the pack:'
Write-Host ' winapp new -t reactor -n MyApp'
} elseif (-not $templatesVerified) {
# Same false promise, for the harder case: the pack is installed but step 5
# proved `dotnet new reactor` does not resolve from it (an older pack such as
# 0.0.6-alpha predates the Reactor templates).
Write-Host ' `dotnet new reactor` is not available — see the warning above.'
Write-Host ' Install a version that provides it, then scaffold:'
Write-Host ' winapp new --list --template-version latest'
Write-Host ' dotnet new reactor -n MyApp'
} else {
Write-Host ' dotnet new reactor -n MyApp'
Write-Host ' cd MyApp'
Write-Host ' dotnet run'
Write-Host ''
# `reactor-singlefile` arrived in a later pack than the other four, and step
# 5 keeps an already-installed older pack, so name it only when this
# machine's pack provides it — the same false-promise rule as above. Same
# whole-token, case-sensitive match as step 5 and bootstrap.yml: a plain
# substring also hits `winui-reactor-singlefile` and the no-match hint.
#
# With no match, `dotnet new list` writes to stderr and exits 103. Windows
# PowerShell 5.1 turns redirected native stderr into error records, which
# the script-wide 'Stop' makes terminating: bootstrap would die after
# printing "Bootstrap complete." So the probe runs under 'Continue', scoped
# to its own script block.
$otherTemplates = @('reactor-mvu', 'reactor-navview', 'reactor-tabview')
$singleFileListing = & {
$ErrorActionPreference = 'Continue'
& dotnet new list reactor-singlefile 2>&1 | Out-String
}
if ($LASTEXITCODE -eq 0 -and
$singleFileListing -notmatch 'No templates found' -and
$singleFileListing -cmatch '(?<![^\s,])reactor-singlefile(?![^\s,])') {
$otherTemplates += 'reactor-singlefile'
}
Write-Host "Other Reactor templates: $($otherTemplates -join ', ')"
Write-Host ' dotnet new list reactor'
}
Write-Host ''
Write-Host 'Other useful commands:'
Write-Host ' mur doctor verify your install'
Write-Host ' mur upgrade refresh local packages + plugin after `git pull`'
Write-Host ' mur --help full command list'
Write-Host ''
Write-Host 'Run the E2E UI tests (needs the winapp CLI installed above):'
Write-Host " dotnet test tests/Reactor.AppTests -c Debug -p:Platform=$hostArch"
Write-Host ''
Write-Host 'Visual Studio preview (if VS installed): View -> Other Windows -> Reactor Preview'
# Every hard failure above exits via Fail (exit 1), so reaching here means
# success. Say so explicitly: bootstrap.yml runs this script *in-process* and