@@ -520,6 +520,17 @@ function TestUsingRunTests() {
520520 Write-Host " No VsProjectFault logs found to copy"
521521 }
522522
523+ if ($vsId ) {
524+ $activityLogPath = Join-Path ${env: USERPROFILE} " AppData\Roaming\Microsoft\VisualStudio\$vsMajorVersion .0_$ ( $vsId ) $hive \ActivityLog.xml"
525+ $devenvExeConfig = Join-Path ${env: USERPROFILE} " AppData\Local\Microsoft\VisualStudio\$vsMajorVersion .0_$ ( $vsId ) $hive \devenv.exe.config"
526+ $mefErrors = Join-Path ${env: USERPROFILE} " AppData\Local\Microsoft\VisualStudio\$vsMajorVersion .0_$ ( $vsId ) $hive \ComponentModelCache\Microsoft.VisualStudio.Default.err"
527+ CopyToArtifactLogs $activityLogPath
528+ CopyToArtifactLogs $devenvExeConfig
529+ CopyToArtifactLogs $mefErrors
530+ } else {
531+ Write-Host " No Visual Studio instance found to copy logs from"
532+ }
533+
523534 if ($lspEditor ) {
524535 $lspLogs = Join-Path $TempDir " VSLogs"
525536 $telemetryLog = Join-Path $TempDir " VSTelemetryLog"
@@ -541,96 +552,120 @@ function TestUsingRunTests() {
541552 }
542553}
543554
555+ function CopyToArtifactLogs ($inputPath ) {
556+ if (Test-Path $inputPath ) {
557+ Write-Host " Copying $inputPath to $LogDir "
558+ Copy-Item - Path $inputPath - Destination $LogDir
559+ } else {
560+ Write-Host " No log found to copy at $inputPath "
561+ }
562+ }
563+
544564# Deploy our core VSIX libraries to Visual Studio via the Roslyn VSIX tool. This is an alternative to
545565# deploying at build time.
546566function Deploy-VsixViaTool () {
547567
568+ # Create a log file name for vsix installation. The vsix installer will append to this log (not overwrite)
569+ # so we can re-use the same log file for all our install operations.
570+ # VSIX installer will always write the log file to %temp% and ignores full paths.
571+ $logFileName = " VSIXInstaller-" + [guid ]::NewGuid().ToString() + " .log"
572+
548573 $vsInfo = LocateVisualStudio
549574 if ($vsInfo -eq $null ) {
550575 throw " Unable to locate required Visual Studio installation"
551576 }
552577
553- $vsDir = $vsInfo.installationPath.TrimEnd (" \" )
554- $vsId = $vsInfo.instanceId
555- $vsMajorVersion = $vsInfo.installationVersion.Split (' .' )[0 ]
556- $displayVersion = $vsInfo.catalog.productDisplayVersion
578+ try {
579+ $vsDir = $vsInfo.installationPath.TrimEnd (" \" )
580+ $script :vsId = $vsInfo.instanceId
581+ $script :vsMajorVersion = $vsInfo.installationVersion.Split (' .' )[0 ]
582+ $displayVersion = $vsInfo.catalog.productDisplayVersion
557583
558- $hive = " RoslynDev"
559- Write-Host " Using VS Instance $vsId ($displayVersion ) at `" $vsDir `" "
560- $baseArgs = " /rootSuffix:$hive /quiet /shutdownprocesses"
584+ $script :hive = " RoslynDev"
561585
562- Write-Host " Uninstalling old Roslyn VSIX "
586+ Write-Host " Using VS Instance $vsId ( $displayVersion ) at `" $vsDir `" "
563587
564- # Actual uninstall is failing at the moment using the uninstall options. Temporarily using
565- # wildfire to uninstall our VSIX extensions
566- $extDir = Join-Path ${env: USERPROFILE} " AppData\Local\Microsoft\VisualStudio\$vsMajorVersion .0_$vsid$hive "
567- if (Test-Path $extDir ) {
568- foreach ($dir in Get-ChildItem - Directory $extDir ) {
569- $name = Split-Path - leaf $dir
570- Write-Host " `t Uninstalling $name "
571- }
572- Remove-Item - re - fo $extDir
573- }
588+ # InstanceIds is required here to ensure it installs the vsixes only into the specified VS instance.
589+ # The default installer behavior without it is to install into every installed VS instance.
590+ $baseArgs = " /rootSuffix:$hive /quiet /shutdownprocesses /instanceIds:$vsId /logFile:$logFileName "
574591
575- Write-Host " Installing all Roslyn VSIX "
592+ $vsixInstallerExe = Join-Path $vsDir " Common7\IDE\VSIXInstaller.exe "
576593
577- # VSIX files need to be installed in this specific order:
578- $orderedVsixFileNames = @ (
579- " Roslyn.Compilers.Extension.vsix" ,
580- " Roslyn.VisualStudio.Setup.vsix" ,
581- " Roslyn.VisualStudio.ServiceHub.Setup.x64.vsix" ,
582- " Roslyn.VisualStudio.Setup.Dependencies.vsix" ,
583- " ExpressionEvaluatorPackage.vsix" ,
584- " Roslyn.VisualStudio.DiagnosticsWindow.vsix" ,
585- " Microsoft.VisualStudio.IntegrationTest.Setup.vsix" )
594+ Write-Host " Uninstalling old Roslyn VSIX"
586595
587- foreach ($vsixFileName in $orderedVsixFileNames ) {
588- $vsixFile = Join-Path $VSSetupDir $vsixFileName
589- $vsixInstallerExe = Join-Path $vsDir " Common7\IDE\VSIXInstaller.exe"
590- $fullArg = " $baseArgs $vsixFile "
591- Write-Host " `t Installing $vsixFileName "
592- Exec- Command $vsixInstallerExe $fullArg
593- }
596+ # Actual uninstall is failing at the moment using the uninstall options. Temporarily using
597+ # wildfire to uninstall our VSIX extensions
598+ $extDir = Join-Path ${env: USERPROFILE} " AppData\Local\Microsoft\VisualStudio\$vsMajorVersion .0_$vsid$hive "
599+ if (Test-Path $extDir ) {
600+ foreach ($dir in Get-ChildItem - Directory $extDir ) {
601+ $name = Split-Path - leaf $dir
602+ Write-Host " `t Uninstalling $name "
603+ }
604+ Remove-Item - re - fo $extDir
605+ }
594606
595- # Set up registry
596- $vsRegEdit = Join-Path (Join-Path (Join-Path $vsDir ' Common7' ) ' IDE' ) ' VsRegEdit.exe'
607+ Write-Host " Installing all Roslyn VSIX"
608+
609+ # VSIX files need to be installed in this specific order:
610+ $orderedVsixFileNames = @ (
611+ " Roslyn.Compilers.Extension.vsix" ,
612+ " Roslyn.VisualStudio.Setup.vsix" ,
613+ " Roslyn.VisualStudio.ServiceHub.Setup.x64.vsix" ,
614+ " Roslyn.VisualStudio.Setup.Dependencies.vsix" ,
615+ " ExpressionEvaluatorPackage.vsix" ,
616+ " Roslyn.VisualStudio.DiagnosticsWindow.vsix" ,
617+ " Microsoft.VisualStudio.IntegrationTest.Setup.vsix" )
618+
619+ foreach ($vsixFileName in $orderedVsixFileNames ) {
620+ $vsixFile = Join-Path $VSSetupDir $vsixFileName
621+ $fullArg = " $baseArgs $vsixFile "
622+ Write-Host " `t Installing $vsixFileName "
623+ Exec- Command $vsixInstallerExe $fullArg
624+ }
597625
598- # Disable roaming settings to avoid interference from the online user profile
599- & $vsRegEdit set " $vsDir " $hive HKCU " ApplicationPrivateSettings\Microsoft\VisualStudio " RoamingEnabled string " 1*System.Boolean*False "
626+ # Set up registry
627+ $vsRegEdit = Join-Path ( Join-Path ( Join-Path $vsDir ' Common7 ' ) ' IDE ' ) ' VsRegEdit.exe '
600628
601- # Disable IntelliCode line completions to avoid interference with argument completion testing
602- & $vsRegEdit set " $vsDir " $hive HKCU " ApplicationPrivateSettings\Microsoft\VisualStudio\IntelliCode " wholeLineCompletions string " 0 *System.Int32*2 "
629+ # Disable roaming settings to avoid interference from the online user profile
630+ & $vsRegEdit set " $vsDir " $hive HKCU " ApplicationPrivateSettings\Microsoft\VisualStudio" RoamingEnabled string " 1 *System.Boolean*False "
603631
604- # Disable IntelliCode RepositoryAttachedModels since it requires authentication which can fail in CI
605- & $vsRegEdit set " $vsDir " $hive HKCU " ApplicationPrivateSettings\Microsoft\VisualStudio\IntelliCode" repositoryAttachedModels string " 0*System.Int32*2"
632+ # Disable IntelliCode line completions to avoid interference with argument completion testing
633+ & $vsRegEdit set " $vsDir " $hive HKCU " ApplicationPrivateSettings\Microsoft\VisualStudio\IntelliCode" wholeLineCompletions string " 0*System.Int32*2"
606634
607- # Disable background download UI to avoid toasts
608- & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Setup\BackgroundDownload " Value dword 0
635+ # Disable IntelliCode RepositoryAttachedModels since it requires authentication which can fail in CI
636+ & $vsRegEdit set " $vsDir " $hive HKCU " ApplicationPrivateSettings\Microsoft\VisualStudio\IntelliCode " repositoryAttachedModels string " 0*System.Int32*2 "
609637
610- # Disable text spell checker to avoid spurious warnings in the error list
611- & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Editor\EnableSpellChecker " Value dword 0
638+ # Disable background download UI to avoid toasts
639+ & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Setup\BackgroundDownload " Value dword 0
612640
613- # Run source generators automatically during integration tests.
614- & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Roslyn\SourceGeneratorExecutionBalanced " Value dword 0
641+ # Disable text spell checker to avoid spurious warnings in the error list
642+ & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Editor\EnableSpellChecker " Value dword 0
615643
616- # Configure LSP
617- $lspRegistryValue = [int ]$lspEditor.ToBool ()
618- & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Roslyn\LSP\Editor" Value dword $lspRegistryValue
619- & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Lsp\PullDiagnostics" Value dword 1
644+ # Run source generators automatically during integration tests.
645+ & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Roslyn\SourceGeneratorExecutionBalanced" Value dword 0
620646
621- # Disable text editor error reporting because it pops up a dialog. We want to either fail fast in our
622- # custom handler or fail silently and continue testing.
623- & $vsRegEdit set " $vsDir " $hive HKCU " Text Editor" " Report Exceptions" dword 0
647+ # Configure LSP
648+ $lspRegistryValue = [int ]$lspEditor.ToBool ()
649+ & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Roslyn\LSP\Editor" Value dword $lspRegistryValue
650+ & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Lsp\PullDiagnostics" Value dword 1
624651
625- # Configure RemoteHostOptions.OOP64Bit for testing
626- $oop64bitValue = [ int ] $oop64bit .ToBool ()
627- & $vsRegEdit set " $vsDir " $hive HKCU " Roslyn\Internal\OnOff\Features " OOP64Bit dword $oop64bitValue
652+ # Disable text editor error reporting because it pops up a dialog. We want to either fail fast in our
653+ # custom handler or fail silently and continue testing.
654+ & $vsRegEdit set " $vsDir " $hive HKCU " Text Editor " " Report Exceptions " dword 0
628655
629- # Disable targeted notifications
630- if ($ci ) {
631- # Currently does not work via vsregedit, so only apply this setting in CI
632- # &$vsRegEdit set "$vsDir" $hive HKCU "RemoteSettings" TurnOffSwitch dword 1
633- reg add hkcu\Software\Microsoft\VisualStudio\RemoteSettings / f / t REG_DWORD / v TurnOffSwitch / d 1
656+ # Configure RemoteHostOptions.OOP64Bit for testing
657+ $oop64bitValue = [int ]$oop64bit.ToBool ()
658+ & $vsRegEdit set " $vsDir " $hive HKCU " Roslyn\Internal\OnOff\Features" OOP64Bit dword $oop64bitValue
659+
660+ # Disable targeted notifications
661+ if ($ci ) {
662+ # Currently does not work via vsregedit, so only apply this setting in CI
663+ # &$vsRegEdit set "$vsDir" $hive HKCU "RemoteSettings" TurnOffSwitch dword 1
664+ reg add hkcu\Software\Microsoft\VisualStudio\RemoteSettings / f / t REG_DWORD / v TurnOffSwitch / d 1
665+ }
666+ } finally {
667+ $vsixInstallerLogs = Join-Path $TempDir $logFileName
668+ CopyToArtifactLogs $vsixInstallerLogs
634669 }
635670}
636671
0 commit comments