diff --git a/eng/build-utils.ps1 b/eng/build-utils.ps1 index 0dcf9bdcb5d1b..6d75e98b14307 100644 --- a/eng/build-utils.ps1 +++ b/eng/build-utils.ps1 @@ -287,3 +287,30 @@ function Make-BootstrapBuild() { return $dir } + +Add-Type -AssemblyName 'System.Drawing' +Add-Type -AssemblyName 'System.Windows.Forms' +function Capture-Screenshot($path) { + $width = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width + $height = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height + + $bitmap = New-Object System.Drawing.Bitmap $width, $height + try { + $graphics = [System.Drawing.Graphics]::FromImage($bitmap) + try { + $graphics.CopyFromScreen( ` + [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.X, ` + [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Y, ` + 0, ` + 0, ` + $bitmap.Size, ` + [System.Drawing.CopyPixelOperation]::SourceCopy) + } finally { + $graphics.Dispose() + } + + $bitmap.Save($path, [System.Drawing.Imaging.ImageFormat]::Png) + } finally { + $bitmap.Dispose() + } +} diff --git a/eng/build.ps1 b/eng/build.ps1 index 40479e05314b3..9a346142d130f 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -370,7 +370,7 @@ function TestUsingOptimizedRunner() { if ($ci) { $args += " -xml" if ($testVsi) { - $args += " -timeout:120" + $args += " -timeout:110" } else { $args += " -timeout:65" } @@ -505,6 +505,47 @@ try { if ($ci) { List-Processes Prepare-TempDir + + if ($testVsi) { + $screenshotPath = (Join-Path $LogDir "StartingBuild.png") + try { + Capture-Screenshot $screenshotPath + } + catch { + Write-Host "Screenshot failed; attempting to connect to the console" + + # Keep the session open so we have a UI to interact with + $quserItems = ((quser $env:USERNAME | select -Skip 1) -split '\s+') + $sessionid = $quserItems[2] + if ($sessionid -eq 'Disc') { + # When the session isn't connected, the third value is 'Disc' instead of the ID + $sessionid = $quserItems[1] + } + + if ($quserItems[1] -eq 'console') { + Write-Host "Disconnecting from console before attempting reconnection" + try { + tsdiscon + } catch { + # ignore + } + + # Disconnection is asynchronous, so wait a few seconds for it to complete + Start-Sleep -Seconds 3 + query user + } + + Write-Host "tscon $sessionid /dest:console" + tscon $sessionid /dest:console + + # Connection is asynchronous, so wait a few seconds for it to complete + Start-Sleep 3 + query user + + # Make sure we can capture a screenshot. An exception at this point will fail-fast the build. + Capture-Screenshot $screenshotPath + } + } } if ($bootstrap) { diff --git a/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicRename.cs b/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicRename.cs index 36ad941dbce71..72a7260e6fd75 100644 --- a/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicRename.cs +++ b/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicRename.cs @@ -213,8 +213,8 @@ Inherits Attribute VisualStudio.Editor.Verify.TextContains(@" Import System; -Public Class CustomAttribute - Inherits Attribute +Public Class CustomAttribute + Inherits Attribute End Class"); } @@ -333,7 +333,7 @@ Inherits Attribute Import System; Public Class CustomAttribute - Inherits Attribute + Inherits Attribute End Class"); } @@ -359,7 +359,7 @@ Inherits Attribute Import System; Public Class CustomAttribute - Inherits Attribute + Inherits Attribute End Class"); } } diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs b/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs index ec70469e4ca7a..cc42d3bbc9365 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs @@ -324,6 +324,9 @@ private static Process StartNewVisualStudioProcess(string installationPath, int // Disable roaming settings to avoid interference from the online user profile Process.Start(vsRegEditExeFile, $"set \"{installationPath}\" {Settings.Default.VsRootSuffix} HKCU \"ApplicationPrivateSettings\\Microsoft\\VisualStudio\" RoamingEnabled string \"1*System.Boolean*False\"").WaitForExit(); + // Disable async completion for 16.0 Preview 3 testing + Process.Start(vsRegEditExeFile, $"set \"{installationPath}\" {Settings.Default.VsRootSuffix} HKCU \"ApplicationPrivateSettings\\WindowManagement\\Options\" UseAsyncCompletion string \"1*System.Int32*-1\"").WaitForExit(); + // Disable text editor error reporting because it pops up a dialog. We want to either fail fast in our // custom handler or fail silently and continue testing. Process.Start(vsRegEditExeFile, $"set \"{installationPath}\" {Settings.Default.VsRootSuffix} HKCU \"Text Editor\" \"Report Exceptions\" dword 0").WaitForExit();