From e19ccb0b41191713b9a27e586106c8b8ae521492 Mon Sep 17 00:00:00 2001 From: Logan Bussell Date: Fri, 22 Jul 2022 15:10:08 -0700 Subject: [PATCH 1/9] Change TargetFramework to net7.0 --- .../Microsoft.DotNet.ApiCompat.Task.csproj | 2 +- .../build/Microsoft.DotNet.ApiCompat.Task.targets | 2 +- .../Microsoft.DotNet.ApiCompat.Tool.csproj | 2 +- .../Microsoft.DotNet.ApiCompatibility.csproj | 2 +- .../Microsoft.DotNet.PackageValidation.csproj | 2 +- .../Microsoft.Extensions.DotNetDeltaApplier.csproj | 2 +- .../Microsoft.DotNet.Cli.Utils.csproj | 2 +- src/Layout/redist/targets/GenerateLayout.targets | 6 +++--- src/Layout/redist/targets/OverlaySdkOnLKG.targets | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/Microsoft.DotNet.ApiCompat.Task.csproj b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/Microsoft.DotNet.ApiCompat.Task.csproj index 8177095a9080..0c1f7acebf42 100644 --- a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/Microsoft.DotNet.ApiCompat.Task.csproj +++ b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/Microsoft.DotNet.ApiCompat.Task.csproj @@ -1,7 +1,7 @@  - net6.0;net472 + net7.0;net472 true true Open diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/build/Microsoft.DotNet.ApiCompat.Task.targets b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/build/Microsoft.DotNet.ApiCompat.Task.targets index fb49a12fb4c4..2ce737c75de6 100644 --- a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/build/Microsoft.DotNet.ApiCompat.Task.targets +++ b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/build/Microsoft.DotNet.ApiCompat.Task.targets @@ -2,7 +2,7 @@ $(MSBuildThisFileDirectory)..\tools\net472\Microsoft.DotNet.ApiCompat.Task.dll - $(MSBuildThisFileDirectory)..\tools\net6.0\Microsoft.DotNet.ApiCompat.Task.dll + $(MSBuildThisFileDirectory)..\tools\net7.0\Microsoft.DotNet.ApiCompat.Task.dll true true diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Tool/Microsoft.DotNet.ApiCompat.Tool.csproj b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Tool/Microsoft.DotNet.ApiCompat.Tool.csproj index 2de17ce7157c..32e658092034 100644 --- a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Tool/Microsoft.DotNet.ApiCompat.Tool.csproj +++ b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Tool/Microsoft.DotNet.ApiCompat.Tool.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 Exe enable true diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.csproj b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.csproj index 7b8569a72b51..b1e1e4d53e36 100644 --- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.csproj +++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.csproj @@ -1,7 +1,7 @@  - net6.0;net472 + net7.0;net472 Open enable diff --git a/src/ApiCompat/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj b/src/ApiCompat/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj index aa6de655f57d..fca12f7f67cc 100644 --- a/src/ApiCompat/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj +++ b/src/ApiCompat/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj @@ -1,7 +1,7 @@  - net6.0;net472 + net7.0;net472 Open enable diff --git a/src/BuiltInTools/DotNetDeltaApplier/Microsoft.Extensions.DotNetDeltaApplier.csproj b/src/BuiltInTools/DotNetDeltaApplier/Microsoft.Extensions.DotNetDeltaApplier.csproj index 40927ae1f263..3c2236e38d14 100644 --- a/src/BuiltInTools/DotNetDeltaApplier/Microsoft.Extensions.DotNetDeltaApplier.csproj +++ b/src/BuiltInTools/DotNetDeltaApplier/Microsoft.Extensions.DotNetDeltaApplier.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 MicrosoftAspNetCore false diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj b/src/Cli/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj index 006f56939dc2..ddcfe2e3623e 100644 --- a/src/Cli/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj +++ b/src/Cli/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj @@ -22,7 +22,7 @@ - $(PkgMicrosoft_Build_Runtime)\contentFiles\any\net6.0\MSBuild.dll + $(PkgMicrosoft_Build_Runtime)\contentFiles\any\net7.0\MSBuild.dll diff --git a/src/Layout/redist/targets/GenerateLayout.targets b/src/Layout/redist/targets/GenerateLayout.targets index 85adb4ed8aee..9e26fec65390 100644 --- a/src/Layout/redist/targets/GenerateLayout.targets +++ b/src/Layout/redist/targets/GenerateLayout.targets @@ -27,7 +27,7 @@ $(OutputPath)/Roslyn - + @@ -161,7 +161,7 @@ BeforeTargets="Build"> netcoreapp3.1 - net6.0 + net7.0 $(NuGetPackageRoot)/microsoft.testplatform.cli/$(MicrosoftTestPlatformCLIPackageVersion)/contentFiles/any/$(TestCliNuGetDirectoryTargetFramework)/ @@ -196,7 +196,7 @@ - + diff --git a/src/Layout/redist/targets/OverlaySdkOnLKG.targets b/src/Layout/redist/targets/OverlaySdkOnLKG.targets index b31188d592de..4052c1581b1a 100644 --- a/src/Layout/redist/targets/OverlaySdkOnLKG.targets +++ b/src/Layout/redist/targets/OverlaySdkOnLKG.targets @@ -77,7 +77,7 @@ - + From 2820ef2426c0227e21bed4eb1ab31d48ec257fb1 Mon Sep 17 00:00:00 2001 From: Logan Bussell Date: Thu, 1 Sep 2022 10:40:06 -0700 Subject: [PATCH 2/9] Fix msbuild dll path --- .../Microsoft.DotNet.Cli.Utils.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj b/src/Cli/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj index ddcfe2e3623e..006f56939dc2 100644 --- a/src/Cli/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj +++ b/src/Cli/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj @@ -22,7 +22,7 @@ - $(PkgMicrosoft_Build_Runtime)\contentFiles\any\net7.0\MSBuild.dll + $(PkgMicrosoft_Build_Runtime)\contentFiles\any\net6.0\MSBuild.dll From e99f2b75d33bb0cc1bb9f019f447896e2077d58c Mon Sep 17 00:00:00 2001 From: Logan Bussell Date: Thu, 1 Sep 2022 11:14:43 -0700 Subject: [PATCH 3/9] Target net7.0 in ApiCompat only for source build --- .../Microsoft.DotNet.ApiCompat.Task.csproj | 3 ++- .../build/Microsoft.DotNet.ApiCompat.Task.targets | 3 ++- .../Microsoft.DotNet.ApiCompatibility.csproj | 3 ++- .../Microsoft.DotNet.PackageValidation.csproj | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/Microsoft.DotNet.ApiCompat.Task.csproj b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/Microsoft.DotNet.ApiCompat.Task.csproj index 0c1f7acebf42..f12338b21a5f 100644 --- a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/Microsoft.DotNet.ApiCompat.Task.csproj +++ b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/Microsoft.DotNet.ApiCompat.Task.csproj @@ -1,7 +1,8 @@  - net7.0;net472 + net6.0;net472 + net7.0;net472 true true Open diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/build/Microsoft.DotNet.ApiCompat.Task.targets b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/build/Microsoft.DotNet.ApiCompat.Task.targets index 2ce737c75de6..cd2c97635880 100644 --- a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/build/Microsoft.DotNet.ApiCompat.Task.targets +++ b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Task/build/Microsoft.DotNet.ApiCompat.Task.targets @@ -2,7 +2,8 @@ $(MSBuildThisFileDirectory)..\tools\net472\Microsoft.DotNet.ApiCompat.Task.dll - $(MSBuildThisFileDirectory)..\tools\net7.0\Microsoft.DotNet.ApiCompat.Task.dll + $(MSBuildThisFileDirectory)..\tools\net7.0\Microsoft.DotNet.ApiCompat.Task.dll + $(MSBuildThisFileDirectory)..\tools\net6.0\Microsoft.DotNet.ApiCompat.Task.dll true true diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.csproj b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.csproj index b1e1e4d53e36..3f31507dc92e 100644 --- a/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.csproj +++ b/src/ApiCompat/Microsoft.DotNet.ApiCompatibility/Microsoft.DotNet.ApiCompatibility.csproj @@ -1,7 +1,8 @@  - net7.0;net472 + net6.0;net472 + net7.0;net472 Open enable diff --git a/src/ApiCompat/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj b/src/ApiCompat/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj index fca12f7f67cc..0c91c02884f5 100644 --- a/src/ApiCompat/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj +++ b/src/ApiCompat/Microsoft.DotNet.PackageValidation/Microsoft.DotNet.PackageValidation.csproj @@ -1,7 +1,8 @@  - net7.0;net472 + net6.0;net472 + net7.0;net472 Open enable From c2763fe9deef4403dda200fe0336d26a4fb386e9 Mon Sep 17 00:00:00 2001 From: Logan Bussell Date: Thu, 1 Sep 2022 11:22:16 -0700 Subject: [PATCH 4/9] Fix roslyn TFM --- src/Layout/redist/targets/GenerateLayout.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Layout/redist/targets/GenerateLayout.targets b/src/Layout/redist/targets/GenerateLayout.targets index 9e26fec65390..d399fe6f2985 100644 --- a/src/Layout/redist/targets/GenerateLayout.targets +++ b/src/Layout/redist/targets/GenerateLayout.targets @@ -27,7 +27,7 @@ $(OutputPath)/Roslyn - + From bdaa09fcaf2b51f44c08332c1b07c19ebe2031dc Mon Sep 17 00:00:00 2001 From: Logan Bussell Date: Thu, 1 Sep 2022 16:03:52 -0700 Subject: [PATCH 5/9] Also condition TFM in ApiCompat Tool --- .../Microsoft.DotNet.ApiCompat.Tool.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Tool/Microsoft.DotNet.ApiCompat.Tool.csproj b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Tool/Microsoft.DotNet.ApiCompat.Tool.csproj index 32e658092034..577a5b8e2762 100644 --- a/src/ApiCompat/Microsoft.DotNet.ApiCompat.Tool/Microsoft.DotNet.ApiCompat.Tool.csproj +++ b/src/ApiCompat/Microsoft.DotNet.ApiCompat.Tool/Microsoft.DotNet.ApiCompat.Tool.csproj @@ -1,7 +1,8 @@  - net7.0 + net6.0 + net7.0 Exe enable true From 0f00fc2b2248424fb5ffd4faea1f6dc59d7effe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Matou=C5=A1ek?= Date: Tue, 6 Sep 2022 14:43:41 -0700 Subject: [PATCH 6/9] Remove timeouts from tests (#27700) * Remove timeouts from tests * Fix --- .../dotnet-watch.Tests/BrowserLaunchTests.cs | 4 +- .../dotnet-watch.Tests/DotNetWatcherTests.cs | 22 +++++------ .../dotnet-watch.Tests/GlobbingAppTests.cs | 37 +++++++++---------- .../Utilities/AwaitableProcess.cs | 20 ++++------ .../Utilities/WatchableApp.cs | 19 ++++------ 5 files changed, 46 insertions(+), 56 deletions(-) diff --git a/src/Tests/dotnet-watch.Tests/BrowserLaunchTests.cs b/src/Tests/dotnet-watch.Tests/BrowserLaunchTests.cs index f479dcf9dd88..b74bb546a0bb 100644 --- a/src/Tests/dotnet-watch.Tests/BrowserLaunchTests.cs +++ b/src/Tests/dotnet-watch.Tests/BrowserLaunchTests.cs @@ -37,7 +37,7 @@ public async Task LaunchesBrowserOnStart() await app.StartWatcherAsync(); // Verify we launched the browser. - await app.Process.GetOutputLineStartsWithAsync(expected, TimeSpan.FromMinutes(2)); + await app.Process.GetOutputLineStartsWithAsync(expected); } [Fact] @@ -57,7 +57,7 @@ public async Task UsesBrowserSpecifiedInEnvironment() await app.StartWatcherAsync(); // Verify we launched the browser. - await app.Process.GetOutputLineStartsWithAsync(launchBrowserMessage, TimeSpan.FromMinutes(2)); + await app.Process.GetOutputLineStartsWithAsync(launchBrowserMessage); } } } diff --git a/src/Tests/dotnet-watch.Tests/DotNetWatcherTests.cs b/src/Tests/dotnet-watch.Tests/DotNetWatcherTests.cs index 2efd634a4157..b1e492402114 100644 --- a/src/Tests/dotnet-watch.Tests/DotNetWatcherTests.cs +++ b/src/Tests/dotnet-watch.Tests/DotNetWatcherTests.cs @@ -36,7 +36,7 @@ public async Task RunsWithDotnetWatchEnvVariable() await app.StartWatcherAsync(); const string messagePrefix = "DOTNET_WATCH = "; - var message = await app.Process.GetOutputLineStartsWithAsync(messagePrefix, TimeSpan.FromMinutes(2)); + var message = await app.Process.GetOutputLineStartsWithAsync(messagePrefix); var envValue = message.Substring(messagePrefix.Length); Assert.Equal("1", envValue); } @@ -55,16 +55,16 @@ public async Task RunsWithIterationEnvVariable() var contents = File.ReadAllText(source); const string messagePrefix = "DOTNET_WATCH_ITERATION = "; - var message = await app.Process.GetOutputLineStartsWithAsync(messagePrefix, TimeSpan.FromMinutes(2)); + var message = await app.Process.GetOutputLineStartsWithAsync(messagePrefix); var count = int.Parse(message.Substring(messagePrefix.Length), CultureInfo.InvariantCulture); Assert.Equal(1, count); await app.IsWaitingForFileChange(); File.SetLastWriteTime(source, DateTime.Now); - await app.HasRestarted(TimeSpan.FromMinutes(1)); + await app.HasRestarted(); - message = await app.Process.GetOutputLineStartsWithAsync(messagePrefix, TimeSpan.FromMinutes(2)); + message = await app.Process.GetOutputLineStartsWithAsync(messagePrefix); count = int.Parse(message.Substring(messagePrefix.Length), CultureInfo.InvariantCulture); Assert.Equal(2, count); } @@ -90,7 +90,7 @@ public async Task RunsWithNoRestoreOnOrdinaryFileChanges() for (var i = 0; i < 3; i++) { File.SetLastWriteTime(source, DateTime.Now); - var message = await app.Process.GetOutputLineStartsWithAsync(messagePrefix, TimeSpan.FromMinutes(2)); + var message = await app.Process.GetOutputLineStartsWithAsync(messagePrefix); Assert.Equal(messagePrefix + " --no-restore -- wait", message.Trim()); @@ -117,7 +117,7 @@ public async Task RunsWithRestoreIfCsprojChanges() Assert.Contains(app.Process.Output, p => string.Equals(messagePrefix + " -- wait", p.Trim())); File.SetLastWriteTime(source, DateTime.Now); - var message = await app.Process.GetOutputLineStartsWithAsync(messagePrefix, TimeSpan.FromMinutes(2)); + var message = await app.Process.GetOutputLineStartsWithAsync(messagePrefix); // csproj changed. Do not expect a --no-restore Assert.Equal(messagePrefix + " -- wait", message.Trim()); @@ -126,7 +126,7 @@ public async Task RunsWithRestoreIfCsprojChanges() // regular file changed after csproj changes. Should use --no-restore File.SetLastWriteTime(Path.Combine(app.SourceDirectory, "Program.cs"), DateTime.Now); - message = await app.Process.GetOutputLineStartsWithAsync(messagePrefix, TimeSpan.FromMinutes(2)); + message = await app.Process.GetOutputLineStartsWithAsync(messagePrefix); Assert.Equal(messagePrefix + " --no-restore -- wait", message.Trim()); } @@ -143,7 +143,7 @@ public async Task Run_WithHotReloadEnabled_ReadsLaunchSettings() await app.StartWatcherAsync(); - await app.Process.GetOutputLineAsyncWithConsoleHistoryAsync("Environment: Development", TimeSpan.FromSeconds(10)); + await app.Process.GetOutputLineAsyncWithConsoleHistoryAsync("Environment: Development"); } [Fact(Skip = "https://github.com/dotnet/sdk/issues/24406")] @@ -166,7 +166,7 @@ public async Task Run_WithHotReloadEnabled_ReadsLaunchSettings_WhenUsingProjectO await app.StartWatcherAsync(); - await app.Process.GetOutputLineAsyncWithConsoleHistoryAsync("Environment: Development", TimeSpan.FromSeconds(10)); + await app.Process.GetOutputLineAsyncWithConsoleHistoryAsync("Environment: Development"); } [CoreMSBuildOnlyFact] @@ -192,8 +192,8 @@ public async Task Run_WithHotReloadEnabled_DoesNotReadConsoleIn_InNonInteractive var standardInput = app.Process.Process.StandardInput; var inputString = "This is a test input"; - await standardInput.WriteLineAsync(inputString).WaitAsync(TimeSpan.FromSeconds(10)); - await app.Process.GetOutputLineAsync($"Echo: {inputString}", TimeSpan.FromSeconds(10)); + await standardInput.WriteLineAsync(inputString); + await app.Process.GetOutputLineAsync($"Echo: {inputString}"); } } } diff --git a/src/Tests/dotnet-watch.Tests/GlobbingAppTests.cs b/src/Tests/dotnet-watch.Tests/GlobbingAppTests.cs index d6cbafa2db79..27027c8b98cb 100644 --- a/src/Tests/dotnet-watch.Tests/GlobbingAppTests.cs +++ b/src/Tests/dotnet-watch.Tests/GlobbingAppTests.cs @@ -16,7 +16,6 @@ namespace Microsoft.DotNet.Watcher.Tools public class GlobbingAppTests { private const string AppName = "WatchGlobbingApp"; - private static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(60); private readonly TestAssetsManager _testAssetsManager; private readonly ITestOutputHelper _logger; @@ -38,18 +37,18 @@ public async Task ChangeCompiledFile(bool usePollingWatcher) using var app = new WatchableApp(testAsset, _logger); app.UsePollingWatcher = usePollingWatcher; - await app.StartWatcherAsync().TimeoutAfter(DefaultTimeout); + await app.StartWatcherAsync(); - var types = await GetCompiledAppDefinedTypes(app).TimeoutAfter(DefaultTimeout); + var types = await GetCompiledAppDefinedTypes(app); Assert.Equal(2, types); var fileToChange = Path.Combine(app.SourceDirectory, "include", "Foo.cs"); var programCs = File.ReadAllText(fileToChange); File.WriteAllText(fileToChange, programCs); - await app.HasFileChanged().TimeoutAfter(DefaultTimeout); - await app.HasRestarted().TimeoutAfter(DefaultTimeout); - types = await GetCompiledAppDefinedTypes(app).TimeoutAfter(DefaultTimeout); + await app.HasFileChanged(); + await app.HasRestarted(); + types = await GetCompiledAppDefinedTypes(app); Assert.Equal(2, types); } @@ -62,16 +61,16 @@ public async Task DeleteCompiledFile() using var app = new WatchableApp(testAsset, _logger); - await app.StartWatcherAsync().TimeoutAfter(DefaultTimeout); + await app.StartWatcherAsync(); - var types = await GetCompiledAppDefinedTypes(app).TimeoutAfter(DefaultTimeout); + var types = await GetCompiledAppDefinedTypes(app); Assert.Equal(2, types); var fileToChange = Path.Combine(app.SourceDirectory, "include", "Foo.cs"); File.Delete(fileToChange); - await app.HasRestarted().TimeoutAfter(DefaultTimeout); - types = await GetCompiledAppDefinedTypes(app).TimeoutAfter(DefaultTimeout); + await app.HasRestarted(); + types = await GetCompiledAppDefinedTypes(app); Assert.Equal(1, types); } @@ -84,16 +83,16 @@ public async Task DeleteSourceFolder() using var app = new WatchableApp(testAsset, _logger); - await app.StartWatcherAsync().TimeoutAfter(DefaultTimeout); + await app.StartWatcherAsync(); - var types = await GetCompiledAppDefinedTypes(app).TimeoutAfter(DefaultTimeout); + var types = await GetCompiledAppDefinedTypes(app); Assert.Equal(2, types); var folderToDelete = Path.Combine(app.SourceDirectory, "include"); Directory.Delete(folderToDelete, recursive: true); - await app.HasRestarted().TimeoutAfter(DefaultTimeout); - types = await GetCompiledAppDefinedTypes(app).TimeoutAfter(DefaultTimeout); + await app.HasRestarted(); + types = await GetCompiledAppDefinedTypes(app); Assert.Equal(1, types); } @@ -106,13 +105,13 @@ public async Task RenameCompiledFile() using var app = new WatchableApp(testAsset, _logger); - await app.StartWatcherAsync().TimeoutAfter(DefaultTimeout); + await app.StartWatcherAsync(); var oldFile = Path.Combine(app.SourceDirectory, "include", "Foo.cs"); var newFile = Path.Combine(app.SourceDirectory, "include", "Foo_new.cs"); File.Move(oldFile, newFile); - await app.HasRestarted().TimeoutAfter(DefaultTimeout); + await app.HasRestarted(); } [Fact] @@ -124,7 +123,7 @@ public async Task ChangeExcludedFile() using var app = new WatchableApp(testAsset, _logger); - await app.StartWatcherAsync().TimeoutAfter(DefaultTimeout); + await app.StartWatcherAsync(); var changedFile = Path.Combine(app.SourceDirectory, "exclude", "Baz.cs"); File.WriteAllText(changedFile, ""); @@ -147,7 +146,7 @@ public async Task ListsFiles() app.Start(new[] { "--list" }); var cts = new CancellationTokenSource(); cts.CancelAfter(TimeSpan.FromSeconds(30)); - var lines = await app.Process.GetAllOutputLinesAsync(cts.Token).TimeoutAfter(DefaultTimeout); + var lines = await app.Process.GetAllOutputLinesAsync(cts.Token); var files = lines.Where(l => !l.StartsWith("watch :")); AssertEx.EqualFileList( @@ -163,7 +162,7 @@ public async Task ListsFiles() private async Task GetCompiledAppDefinedTypes(WatchableApp app) { - var definedTypesMessage = await app.Process.GetOutputLineStartsWithAsync("Defined types = ", TimeSpan.FromSeconds(30)); + var definedTypesMessage = await app.Process.GetOutputLineStartsWithAsync("Defined types = "); return int.Parse(definedTypesMessage.Split('=').Last()); } } diff --git a/src/Tests/dotnet-watch.Tests/Utilities/AwaitableProcess.cs b/src/Tests/dotnet-watch.Tests/Utilities/AwaitableProcess.cs index 25282f20916a..dfe789cca537 100644 --- a/src/Tests/dotnet-watch.Tests/Utilities/AwaitableProcess.cs +++ b/src/Tests/dotnet-watch.Tests/Utilities/AwaitableProcess.cs @@ -75,7 +75,7 @@ public void Start() WriteTestOutput($"{DateTime.Now}: process started: '{_process.StartInfo.FileName} {_process.StartInfo.Arguments}'"); } - public Task GetOutputLineAsyncWithConsoleHistoryAsync(string message, TimeSpan timeout) + public Task GetOutputLineAsyncWithConsoleHistoryAsync(string message) { if (_lines.Contains(message)) { @@ -84,23 +84,19 @@ public Task GetOutputLineAsyncWithConsoleHistoryAsync(string message, Ti } WriteTestOutput($"Did not find [msg == '{message}'] in console history."); - return GetOutputLineAsync(message, timeout); + return GetOutputLineAsync(message); } - public async Task GetOutputLineAsync(string message, TimeSpan timeout) + public async Task GetOutputLineAsync(string message) { - WriteTestOutput($"Waiting for output line [msg == '{message}']. Will wait for {timeout.TotalSeconds} sec."); - var cts = new CancellationTokenSource(); - cts.CancelAfter(timeout); - return await GetOutputLineAsync($"[msg == '{message}']", m => string.Equals(m, message, StringComparison.Ordinal), cts.Token); + WriteTestOutput($"Waiting for output line [msg == '{message}']"); + return await GetOutputLineAsync($"[msg == '{message}']", m => string.Equals(m, message, StringComparison.Ordinal), CancellationToken.None); } - public async Task GetOutputLineStartsWithAsync(string message, TimeSpan timeout) + public async Task GetOutputLineStartsWithAsync(string message) { - WriteTestOutput($"Waiting for output line [msg.StartsWith('{message}')]. Will wait for {timeout.TotalSeconds} sec."); - var cts = new CancellationTokenSource(); - cts.CancelAfter(timeout); - return await GetOutputLineAsync($"[msg.StartsWith('{message}')]", m => m != null && m.StartsWith(message, StringComparison.Ordinal), cts.Token); + WriteTestOutput($"Waiting for output line [msg.StartsWith('{message}')]."); + return await GetOutputLineAsync($"[msg.StartsWith('{message}')]", m => m != null && m.StartsWith(message, StringComparison.Ordinal), CancellationToken.None); } private async Task GetOutputLineAsync(string predicateName, Predicate predicate, CancellationToken cancellationToken) diff --git a/src/Tests/dotnet-watch.Tests/Utilities/WatchableApp.cs b/src/Tests/dotnet-watch.Tests/Utilities/WatchableApp.cs index 9a3dc306bdd8..b8e3ec7a2229 100644 --- a/src/Tests/dotnet-watch.Tests/Utilities/WatchableApp.cs +++ b/src/Tests/dotnet-watch.Tests/Utilities/WatchableApp.cs @@ -15,8 +15,6 @@ namespace Microsoft.DotNet.Watcher.Tools { internal sealed class WatchableApp : IDisposable { - private static readonly TimeSpan DefaultMessageTimeOut = TimeSpan.FromSeconds(30); - private const string StartedMessage = "Started"; private const string ExitingMessage = "Exiting"; private const string WatchStartedMessage = "dotnet watch 🚀 Started"; @@ -44,25 +42,22 @@ public WatchableApp(string sourceDirectory, ITestOutputHelper logger) public string WorkingDirectory { get; set; } public Task HasRestarted() - => HasRestarted(DefaultMessageTimeOut); - - public Task HasRestarted(TimeSpan timeout) - => Process.GetOutputLineAsync(StartedMessage, timeout); + => Process.GetOutputLineAsync(StartedMessage); public async Task HasExited() { - await Process.GetOutputLineAsync(ExitingMessage, DefaultMessageTimeOut); - await Process.GetOutputLineStartsWithAsync(WatchExitedMessage, DefaultMessageTimeOut); + await Process.GetOutputLineAsync(ExitingMessage); + await Process.GetOutputLineStartsWithAsync(WatchExitedMessage); } public Task IsWaitingForFileChange() { - return Process.GetOutputLineStartsWithAsync(WaitingForFileChangeMessage, DefaultMessageTimeOut); + return Process.GetOutputLineStartsWithAsync(WaitingForFileChangeMessage); } public Task HasFileChanged() { - return Process.GetOutputLineStartsWithAsync(WatchFileChanged, DefaultMessageTimeOut); + return Process.GetOutputLineStartsWithAsync(WatchFileChanged); } public bool UsePollingWatcher { get; set; } @@ -71,7 +66,7 @@ public async Task GetProcessIdentifier() { // Process ID is insufficient because PID's may be reused. Process identifier also includes other info to distinguish // between different process instances. - var line = await Process.GetOutputLineStartsWithAsync("Process identifier =", DefaultMessageTimeOut); + var line = await Process.GetOutputLineStartsWithAsync("Process identifier ="); return line.Split('=').Last(); } @@ -125,7 +120,7 @@ public async Task StartWatcherAsync(string[] arguments, [CallerMemberName] strin // Make this timeout long because it depends much on the MSBuild compilation speed. // Slow machines may take a bit to compile and boot test apps - await Process.GetOutputLineAsync(WatchStartedMessage, TimeSpan.FromMinutes(2)); + await Process.GetOutputLineAsync(WatchStartedMessage); } public void Dispose() From 442a25e0817f549d527fc86ade8bf31df6e16e9f Mon Sep 17 00:00:00 2001 From: tmat Date: Thu, 8 Sep 2022 11:05:26 -0700 Subject: [PATCH 7/9] Skip failing test PublishClickOnceWithPublishProfile --- .../GivenThatWeWantToPublishToClickOnce.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishToClickOnce.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishToClickOnce.cs index 80ec02bfe065..ecae48b2b7c2 100644 --- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishToClickOnce.cs +++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishToClickOnce.cs @@ -23,7 +23,7 @@ public GivenThatWeWantToPublishAClickOnceProject(ITestOutputHelper log) : base(l { } - [FullMSBuildOnlyTheory] + [FullMSBuildOnlyTheory(Skip = "https://github.com/dotnet/sdk/issues/27766")] [InlineData(false)] [InlineData(true)] public void PublishClickOnceWithPublishProfile(bool? publishSingleFile) From fc4a200f37a8f7ff5abcc39ba4c790dbe62d2a08 Mon Sep 17 00:00:00 2001 From: Logan Bussell Date: Fri, 9 Sep 2022 14:37:51 -0700 Subject: [PATCH 8/9] Update dotnet watch test asset TFM --- .../WatchAppWithLaunchSettings.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Assets/TestProjects/WatchAppWithLaunchSettings/WatchAppWithLaunchSettings.csproj b/src/Assets/TestProjects/WatchAppWithLaunchSettings/WatchAppWithLaunchSettings.csproj index 74abf5c97664..f02677bf640f 100644 --- a/src/Assets/TestProjects/WatchAppWithLaunchSettings/WatchAppWithLaunchSettings.csproj +++ b/src/Assets/TestProjects/WatchAppWithLaunchSettings/WatchAppWithLaunchSettings.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net7.0 enable enable From 2e4328abe166e1f51725ecb1b4f2724c00aa9839 Mon Sep 17 00:00:00 2001 From: Logan Bussell Date: Wed, 14 Sep 2022 10:44:19 -0700 Subject: [PATCH 9/9] Use SDK target framework for source-build instead of hardcoding net6.0 --- Directory.Build.props | 2 ++ .../Microsoft.DotNet.MSBuildSdkResolver.csproj | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index e74d10f1f541..e66d5cf571da 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -17,6 +17,8 @@ net6.0 + + $(SdkTargetFramework) diff --git a/src/Resolvers/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.csproj b/src/Resolvers/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.csproj index fddcbefd6f49..4a1830bd19d6 100644 --- a/src/Resolvers/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.csproj +++ b/src/Resolvers/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.csproj @@ -1,8 +1,8 @@  - net6.0;net472 - net6.0 + $(ResolverTargetFramework);net472 + $(ResolverTargetFramework) AnyCPU win-x86;win-x64 true