@@ -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,6 +552,15 @@ 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+
544564function EnablePreviewSdks () {
545565 $vsInfo = LocateVisualStudio
546566 if ($vsInfo -eq $null ) {
@@ -561,92 +581,110 @@ function EnablePreviewSdks() {
561581# deploying at build time.
562582function Deploy-VsixViaTool () {
563583
584+ # Create a log file name for vsix installation. The vsix installer will append to this log (not overwrite)
585+ # so we can re-use the same log file for all our install operations.
586+ # VSIX installer will always write the log file to %temp% and ignores full paths.
587+ $logFileName = " VSIXInstaller-" + [guid ]::NewGuid().ToString() + " .log"
588+
564589 $vsInfo = LocateVisualStudio
565590 if ($vsInfo -eq $null ) {
566591 throw " Unable to locate required Visual Studio installation"
567592 }
568593
569- $vsDir = $vsInfo.installationPath.TrimEnd (" \" )
570- $vsId = $vsInfo.instanceId
571- $vsMajorVersion = $vsInfo.installationVersion.Split (' .' )[0 ]
572- $displayVersion = $vsInfo.catalog.productDisplayVersion
594+ try {
595+ $vsDir = $vsInfo.installationPath.TrimEnd (" \" )
596+ $script :vsId = $vsInfo.instanceId
597+ $script :vsMajorVersion = $vsInfo.installationVersion.Split (' .' )[0 ]
598+ $displayVersion = $vsInfo.catalog.productDisplayVersion
573599
574- $hive = " RoslynDev"
575- Write-Host " Using VS Instance $vsId ($displayVersion ) at `" $vsDir `" "
576- $baseArgs = " /rootSuffix:$hive /quiet /shutdownprocesses"
600+ $script :hive = " RoslynDev"
577601
578- Write-Host " Uninstalling old Roslyn VSIX "
602+ Write-Host " Using VS Instance $vsId ( $displayVersion ) at `" $vsDir `" "
579603
580- # Actual uninstall is failing at the moment using the uninstall options. Temporarily using
581- # wildfire to uninstall our VSIX extensions
582- $extDir = Join-Path ${env: USERPROFILE} " AppData\Local\Microsoft\VisualStudio\$vsMajorVersion .0_$vsid$hive "
583- if (Test-Path $extDir ) {
584- foreach ($dir in Get-ChildItem - Directory $extDir ) {
585- $name = Split-Path - leaf $dir
586- Write-Host " `t Uninstalling $name "
587- }
588- Remove-Item - re - fo $extDir
589- }
604+ # InstanceIds is required here to ensure it installs the vsixes only into the specified VS instance.
605+ # The default installer behavior without it is to install into every installed VS instance.
606+ $baseArgs = " /rootSuffix:$hive /quiet /shutdownprocesses /instanceIds:$vsId /logFile:$logFileName "
590607
591- Write-Host " Installing all Roslyn VSIX"
608+ # Write the file location out to a variable so we can upload it later.
609+ $fullLogPath = Join-Path $env: TEMP $logFileName
592610
593- # VSIX files need to be installed in this specific order:
594- $orderedVsixFileNames = @ (
595- " Roslyn.Compilers.Extension.vsix" ,
596- " Roslyn.VisualStudio.Setup.vsix" ,
597- " Roslyn.VisualStudio.ServiceHub.Setup.x64.vsix" ,
598- " Roslyn.VisualStudio.Setup.Dependencies.vsix" ,
599- " ExpressionEvaluatorPackage.vsix" ,
600- " Roslyn.VisualStudio.DiagnosticsWindow.vsix" ,
601- " Microsoft.VisualStudio.IntegrationTest.Setup.vsix" )
602-
603- foreach ($vsixFileName in $orderedVsixFileNames ) {
604- $vsixFile = Join-Path $VSSetupDir $vsixFileName
605611 $vsixInstallerExe = Join-Path $vsDir " Common7\IDE\VSIXInstaller.exe"
606- $fullArg = " $baseArgs $vsixFile "
607- Write-Host " `t Installing $vsixFileName "
608- Exec- Command $vsixInstallerExe $fullArg
609- }
610612
611- # Set up registry
612- $vsRegEdit = Join-Path (Join-Path (Join-Path $vsDir ' Common7' ) ' IDE' ) ' VsRegEdit.exe'
613+ Write-Host " Uninstalling old Roslyn VSIX"
613614
614- # Disable roaming settings to avoid interference from the online user profile
615- & $vsRegEdit set " $vsDir " $hive HKCU " ApplicationPrivateSettings\Microsoft\VisualStudio" RoamingEnabled string " 1*System.Boolean*False"
615+ # Actual uninstall is failing at the moment using the uninstall options. Temporarily using
616+ # wildfire to uninstall our VSIX extensions
617+ $extDir = Join-Path ${env: USERPROFILE} " AppData\Local\Microsoft\VisualStudio\$vsMajorVersion .0_$vsid$hive "
618+ if (Test-Path $extDir ) {
619+ foreach ($dir in Get-ChildItem - Directory $extDir ) {
620+ $name = Split-Path - leaf $dir
621+ Write-Host " `t Uninstalling $name "
622+ }
623+ Remove-Item - re - fo $extDir
624+ }
616625
617- # Disable IntelliCode line completions to avoid interference with argument completion testing
618- & $vsRegEdit set " $vsDir " $hive HKCU " ApplicationPrivateSettings\Microsoft\VisualStudio\IntelliCode" wholeLineCompletions string " 0*System.Int32*2"
626+ Write-Host " Installing all Roslyn VSIX"
627+
628+ # VSIX files need to be installed in this specific order:
629+ $orderedVsixFileNames = @ (
630+ " Roslyn.Compilers.Extension.vsix" ,
631+ " Roslyn.VisualStudio.Setup.vsix" ,
632+ " Roslyn.VisualStudio.ServiceHub.Setup.x64.vsix" ,
633+ " Roslyn.VisualStudio.Setup.Dependencies.vsix" ,
634+ " ExpressionEvaluatorPackage.vsix" ,
635+ " Roslyn.VisualStudio.DiagnosticsWindow.vsix" ,
636+ " Microsoft.VisualStudio.IntegrationTest.Setup.vsix" )
637+
638+ foreach ($vsixFileName in $orderedVsixFileNames ) {
639+ $vsixFile = Join-Path $VSSetupDir $vsixFileName
640+ $fullArg = " $baseArgs $vsixFile "
641+ Write-Host " `t Installing $vsixFileName "
642+ Exec- Command $vsixInstallerExe $fullArg
643+ }
619644
620- # Disable IntelliCode RepositoryAttachedModels since it requires authentication which can fail in CI
621- & $vsRegEdit set " $vsDir " $hive HKCU " ApplicationPrivateSettings\Microsoft\VisualStudio\IntelliCode " repositoryAttachedModels string " 0*System.Int32*2 "
645+ # Set up registry
646+ $vsRegEdit = Join-Path ( Join-Path ( Join-Path $vsDir ' Common7 ' ) ' IDE ' ) ' VsRegEdit.exe '
622647
623- # Disable background download UI to avoid toasts
624- & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Setup\BackgroundDownload " Value dword 0
648+ # Disable roaming settings to avoid interference from the online user profile
649+ & $vsRegEdit set " $vsDir " $hive HKCU " ApplicationPrivateSettings\Microsoft\VisualStudio " RoamingEnabled string " 1*System.Boolean*False "
625650
626- # Disable text spell checker to avoid spurious warnings in the error list
627- & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Editor\EnableSpellChecker " Value dword 0
651+ # Disable IntelliCode line completions to avoid interference with argument completion testing
652+ & $vsRegEdit set " $vsDir " $hive HKCU " ApplicationPrivateSettings\Microsoft\VisualStudio\IntelliCode " wholeLineCompletions string " 0*System.Int32*2 "
628653
629- # Run source generators automatically during integration tests.
630- & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Roslyn\SourceGeneratorExecutionBalanced " Value dword 0
654+ # Disable IntelliCode RepositoryAttachedModels since it requires authentication which can fail in CI
655+ & $vsRegEdit set " $vsDir " $hive HKCU " ApplicationPrivateSettings\Microsoft\VisualStudio\IntelliCode " repositoryAttachedModels string " 0*System.Int32*2 "
631656
632- # Configure LSP
633- $lspRegistryValue = [int ]$lspEditor.ToBool ()
634- & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Roslyn\LSP\Editor" Value dword $lspRegistryValue
635- & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Lsp\PullDiagnostics" Value dword 1
657+ # Disable background download UI to avoid toasts
658+ & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Setup\BackgroundDownload" Value dword 0
636659
637- # Disable text editor error reporting because it pops up a dialog. We want to either fail fast in our
638- # custom handler or fail silently and continue testing.
639- & $vsRegEdit set " $vsDir " $hive HKCU " Text Editor" " Report Exceptions" dword 0
660+ # Disable text spell checker to avoid spurious warnings in the error list
661+ & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Editor\EnableSpellChecker" Value dword 0
640662
641- # Configure RemoteHostOptions.OOP64Bit for testing
642- $oop64bitValue = [int ]$oop64bit.ToBool ()
643- & $vsRegEdit set " $vsDir " $hive HKCU " Roslyn\Internal\OnOff\Features" OOP64Bit dword $oop64bitValue
663+ # Run source generators automatically during integration tests.
664+ & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Roslyn\SourceGeneratorExecutionBalanced" Value dword 0
644665
645- # Disable targeted notifications
646- if ($ci ) {
647- # Currently does not work via vsregedit, so only apply this setting in CI
648- # &$vsRegEdit set "$vsDir" $hive HKCU "RemoteSettings" TurnOffSwitch dword 1
649- reg add hkcu\Software\Microsoft\VisualStudio\RemoteSettings / f / t REG_DWORD / v TurnOffSwitch / d 1
666+ # Configure LSP
667+ $lspRegistryValue = [int ]$lspEditor.ToBool ()
668+ & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Roslyn\LSP\Editor" Value dword $lspRegistryValue
669+ & $vsRegEdit set " $vsDir " $hive HKCU " FeatureFlags\Lsp\PullDiagnostics" Value dword 1
670+
671+ # Disable text editor error reporting because it pops up a dialog. We want to either fail fast in our
672+ # custom handler or fail silently and continue testing.
673+ & $vsRegEdit set " $vsDir " $hive HKCU " Text Editor" " Report Exceptions" dword 0
674+
675+ # Configure RemoteHostOptions.OOP64Bit for testing
676+ $oop64bitValue = [int ]$oop64bit.ToBool ()
677+ & $vsRegEdit set " $vsDir " $hive HKCU " Roslyn\Internal\OnOff\Features" OOP64Bit dword $oop64bitValue
678+
679+ # Disable targeted notifications
680+ if ($ci ) {
681+ # Currently does not work via vsregedit, so only apply this setting in CI
682+ # &$vsRegEdit set "$vsDir" $hive HKCU "RemoteSettings" TurnOffSwitch dword 1
683+ reg add hkcu\Software\Microsoft\VisualStudio\RemoteSettings / f / t REG_DWORD / v TurnOffSwitch / d 1
684+ }
685+ } finally {
686+ $vsixInstallerLogs = Join-Path $TempDir $logFileName
687+ CopyToArtifactLogs $vsixInstallerLogs
650688 }
651689}
652690
0 commit comments