Skip to content

Commit 703ddef

Browse files
Copilottmat
authored andcommitted
Fix stdout suppression in dotnet watch with --no-hot-reload (#52836)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tmat <41759+tmat@users.noreply.github.com> Fix
1 parent 1fba7bf commit 703ddef

File tree

128 files changed

+338
-316
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+338
-316
lines changed

src/Dotnet.Watch/dotnet-watch/Watch/DotNetWatcher.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ public static async Task WatchAsync(DotNetWatchContext context, CancellationToke
5858
{
5959
[EnvironmentVariables.Names.DotnetWatch] = "1",
6060
[EnvironmentVariables.Names.DotnetWatchIteration] = (iteration + 1).ToString(CultureInfo.InvariantCulture),
61-
}
61+
},
62+
OnOutput = line => context.ProcessOutputReporter.ReportOutput(line)
6263
};
6364

6465
var browserRefreshServer = projectRootNode != null && HotReloadAppModel.InferFromProject(context, projectRootNode) is WebApplicationAppModel webAppModel

test/ArgumentForwarding.Tests/ArgumentForwardingTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ private string[] RawEvaluateArgumentString(string testUserArgument)
250250
{
251251
StartInfo = new ProcessStartInfo
252252
{
253-
FileName = TestContext.Current.ToolsetUnderTest.DotNetHostPath,
253+
FileName = SdkTestContext.Current.ToolsetUnderTest.DotNetHostPath,
254254
Arguments = $"{ReflectorPath} {testUserArgument}",
255255
UseShellExecute = false,
256256
RedirectStandardOutput = true,

test/Common/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private static int ShowSdkInfo()
6868
{
6969
var log = new StringTestLogger();
7070
var command = new DotnetCommand(log, "--info");
71-
var testDirectory = TestDirectory.Create(Path.Combine(TestContext.Current.TestExecutionDirectory, "sdkinfo"));
71+
var testDirectory = TestDirectory.Create(Path.Combine(SdkTestContext.Current.TestExecutionDirectory, "sdkinfo"));
7272

7373
command.WorkingDirectory = testDirectory.Path;
7474

test/EndToEnd.Tests/GivenDotNetUsesMSBuild.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void ItCanRunToolsInACSProj()
5959
project.Root.Add(itemGroup);
6060
});
6161

62-
NuGetConfigWriter.Write(testInstance.Path, TestContext.Current.TestPackages);
62+
NuGetConfigWriter.Write(testInstance.Path, SdkTestContext.Current.TestPackages);
6363

6464
new RestoreCommand(testInstance)
6565
.Execute()
@@ -93,7 +93,7 @@ public void ItCanRunToolsThatPrefersTheCliRuntimeEvenWhenTheToolItselfDeclaresAD
9393
project.Root.Add(itemGroup);
9494
});
9595

96-
NuGetConfigWriter.Write(testInstance.Path, TestContext.Current.TestPackages);
96+
NuGetConfigWriter.Write(testInstance.Path, SdkTestContext.Current.TestPackages);
9797

9898
new RestoreCommand(testInstance)
9999
.Execute()

test/EndToEnd.Tests/ProjectBuildTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ public void ItCanCreateAndBuildTemplatesWithDefaultFramework_DisableBuildOnLinux
402402

403403
private static string DetectExpectedDefaultFramework(string template = "")
404404
{
405-
string dotnetFolder = Path.GetDirectoryName(TestContext.Current.ToolsetUnderTest.DotNetHostPath);
405+
string dotnetFolder = Path.GetDirectoryName(SdkTestContext.Current.ToolsetUnderTest.DotNetHostPath);
406406
string[] runtimeFolders = Directory.GetDirectories(Path.Combine(dotnetFolder, "shared", "Microsoft.NETCore.App"));
407407
int latestMajorVersion = runtimeFolders.Select(folder => int.Parse(Path.GetFileName(folder).Split('.').First())).Max();
408408
if (latestMajorVersion == 10)
@@ -468,7 +468,7 @@ XDocument GetProjectXml()
468468
$"/bl:{templateName}-{(selfContained ? "selfcontained" : "fdd")}-{language}-{framework}-{{}}.binlog"
469469
];
470470

471-
string dotnetRoot = Path.GetDirectoryName(TestContext.Current.ToolsetUnderTest.DotNetHostPath);
471+
string dotnetRoot = Path.GetDirectoryName(SdkTestContext.Current.ToolsetUnderTest.DotNetHostPath);
472472
new DotnetBuildCommand(Log, projectDirectory)
473473
.WithEnvironmentVariable("PATH", dotnetRoot) // override PATH since razor rely on PATH to find dotnet
474474
.WithWorkingDirectory(projectDirectory)

test/EndToEnd.Tests/ValidateInsertedManifests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class ValidateInsertedManifests(ITestOutputHelper log) : SdkTest(log)
1212
[Fact]
1313
public void ManifestReaderCanReadManifests()
1414
{
15-
var sdkManifestDir = Path.Combine(Path.GetDirectoryName(TestContext.Current.ToolsetUnderTest.DotNetHostPath), "sdk-manifests");
15+
var sdkManifestDir = Path.Combine(Path.GetDirectoryName(SdkTestContext.Current.ToolsetUnderTest.DotNetHostPath), "sdk-manifests");
1616
var sdkversionDir = new DirectoryInfo(sdkManifestDir).EnumerateDirectories().First();
1717
foreach (var manifestVersionDir in sdkversionDir.EnumerateDirectories())
1818
{

test/EndToEnd.Tests/VersionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public void DotnetVersionReturnsCorrectVersion()
1313
var result = new DotnetCommand(Log).Execute("--version");
1414
result.Should().Pass();
1515

16-
var dotnetFolder = Path.GetDirectoryName(TestContext.Current.ToolsetUnderTest.DotNetHostPath);
16+
var dotnetFolder = Path.GetDirectoryName(SdkTestContext.Current.ToolsetUnderTest.DotNetHostPath);
1717
var sdkFolders = Directory.GetDirectories(Path.Combine(dotnetFolder, "sdk"));
1818
sdkFolders.Length.Should().Be(1, "Only one SDK folder is expected in the layout");
1919

test/Microsoft.DotNet.HotReload.Test.Utilities/WatchableApp.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal sealed class WatchableApp(
1919
: IAsyncDisposable
2020
{
2121
public static WatchableApp CreateDotnetWatchApp(ITestOutputHelper logger)
22-
=> new(logger, TestContext.Current.ToolsetUnderTest.DotNetHostPath, "watch", ["-bl"]);
22+
=> new(logger, SdkTestContext.Current.ToolsetUnderTest.DotNetHostPath, "watch", ["-bl"]);
2323

2424
public DebugTestOutputLogger Logger { get; } = new DebugTestOutputLogger(logger);
2525

@@ -217,7 +217,7 @@ public ProcessStartInfo GetProcessStartInfo(string workingDirectory, string test
217217
info.Environment[name] = value;
218218
}
219219

220-
TestContext.Current.AddTestEnvironmentVariables(info.Environment);
220+
SdkTestContext.Current.AddTestEnvironmentVariables(info.Environment);
221221

222222
return info;
223223
}

test/Microsoft.DotNet.HotReload.Watch.Aspire.Tests/AspireLauncherTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ private WatchableApp CreateHostApp()
1717
Logger,
1818
executablePath: Path.ChangeExtension(typeof(AspireLauncher).Assembly.Location, PathUtilities.ExecutableExtension).TrimEnd('.'),
1919
commandName: "host",
20-
commandArguments: ["--sdk", TestContext.Current.ToolsetUnderTest.SdkFolderUnderTest]);
20+
commandArguments: ["--sdk", SdkTestContext.Current.ToolsetUnderTest.SdkFolderUnderTest]);
2121

2222
private WatchableApp CreateServerApp(string serverPipe)
2323
=> new(
2424
Logger,
2525
executablePath: Path.ChangeExtension(typeof(AspireLauncher).Assembly.Location, PathUtilities.ExecutableExtension).TrimEnd('.'),
2626
commandName: "server",
27-
commandArguments: ["--sdk", TestContext.Current.ToolsetUnderTest.SdkFolderUnderTest, "--server", serverPipe]);
27+
commandArguments: ["--sdk", SdkTestContext.Current.ToolsetUnderTest.SdkFolderUnderTest, "--server", serverPipe]);
2828

2929
private WatchableApp CreateResourceApp(string serverPipe)
3030
=> new(

test/Microsoft.DotNet.PackageInstall.Tests/TestToolBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public string GetIdentifier() {
100100

101101
public string CreateTestTool(ITestOutputHelper log, TestToolSettings toolSettings, bool collectBinlogs = true)
102102
{
103-
var targetDirectory = Path.Combine(TestContext.Current.TestExecutionDirectory, "TestTools", toolSettings.GetIdentifier());
103+
var targetDirectory = Path.Combine(SdkTestContext.Current.TestExecutionDirectory, "TestTools", toolSettings.GetIdentifier());
104104

105105
var testProject = new TestProject(toolSettings.ToolPackageId)
106106
{

0 commit comments

Comments
 (0)