diff --git a/src/Microsoft.DotNet.Watcher.Tools/Microsoft.DotNet.Watcher.Tools.csproj b/src/Microsoft.DotNet.Watcher.Tools/Microsoft.DotNet.Watcher.Tools.csproj index 6858eb7e49..fb08e53fcf 100644 --- a/src/Microsoft.DotNet.Watcher.Tools/Microsoft.DotNet.Watcher.Tools.csproj +++ b/src/Microsoft.DotNet.Watcher.Tools/Microsoft.DotNet.Watcher.Tools.csproj @@ -3,11 +3,10 @@ netcoreapp1.0 dotnet-watch - Exe + exe Command line tool to watch for source file changes during development and restart the dotnet command. dotnet;watch - @@ -15,7 +14,6 @@ - diff --git a/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/AwaitableProcess.cs b/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/AwaitableProcess.cs index fc920e7eb0..2abbdf9068 100644 --- a/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/AwaitableProcess.cs +++ b/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/AwaitableProcess.cs @@ -8,9 +8,9 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using System.Threading.Tasks.Dataflow; -using Microsoft.DotNet.Cli.Utils; using Microsoft.Extensions.Internal; using Xunit.Abstractions; +using Microsoft.Extensions.Tools.Internal; namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests { @@ -40,7 +40,7 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests UseShellExecute = false, FileName = _spec.Executable, WorkingDirectory = _spec.WorkingDirectory, - Arguments = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(_spec.Arguments), + Arguments = ArgumentEscaper.EscapeAndConcatenate(_spec.Arguments), RedirectStandardOutput = true, RedirectStandardError = true }; diff --git a/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/Microsoft.DotNet.Watcher.Tools.FunctionalTests.csproj b/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/Microsoft.DotNet.Watcher.Tools.FunctionalTests.csproj index ffcad2484b..274d05f92e 100644 --- a/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/Microsoft.DotNet.Watcher.Tools.FunctionalTests.csproj +++ b/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/Microsoft.DotNet.Watcher.Tools.FunctionalTests.csproj @@ -13,7 +13,6 @@ - diff --git a/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/Scenario/ProjectToolScenario.cs b/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/Scenario/ProjectToolScenario.cs index 080b07aa8a..effcb9de32 100644 --- a/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/Scenario/ProjectToolScenario.cs +++ b/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/Scenario/ProjectToolScenario.cs @@ -1,12 +1,13 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.Extensions.Tools.Internal; using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Reflection; using System.Threading; -using Microsoft.DotNet.Cli.Utils; using Xunit.Abstractions; namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests @@ -69,18 +70,36 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests private void ExecuteCommand(string project, params string[] arguments) { project = Path.Combine(WorkFolder, project); - var command = Command - .Create(new Muxer().MuxerPath, arguments) - .WorkingDirectory(project) - .CaptureStdErr() - .CaptureStdOut() - .OnErrorLine(l => _logger?.WriteLine(l)) - .OnOutputLine(l => _logger?.WriteLine(l)) - .Execute(); - - if (command.ExitCode != 0) + var psi = new ProcessStartInfo { - throw new InvalidOperationException($"Exit code {command.ExitCode}"); + FileName = DotNetMuxer.MuxerPathOrDefault(), + Arguments = ArgumentEscaper.EscapeAndConcatenate(arguments), + WorkingDirectory = project, + RedirectStandardOutput = true, + RedirectStandardError = true + }; + + var process = new Process() + { + StartInfo = psi, + EnableRaisingEvents = true + }; + + void WriteLine(object sender, DataReceivedEventArgs args) + => _logger.WriteLine(args.Data); + + process.ErrorDataReceived += WriteLine; + process.OutputDataReceived += WriteLine; + + process.Start(); + process.WaitForExit(); + + process.ErrorDataReceived -= WriteLine; + process.OutputDataReceived -= WriteLine; + + if (process.ExitCode != 0) + { + throw new InvalidOperationException($"Exit code {process.ExitCode}"); } } @@ -103,10 +122,10 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests args.Add("exec"); args.Add("--depsfile"); - args.Add(Path.Combine(AppContext.BaseDirectory, thisAssembly + FileNameSuffixes.DepsJson)); + args.Add(Path.Combine(AppContext.BaseDirectory, thisAssembly + ".deps.json")); args.Add("--runtimeconfig"); - args.Add(Path.Combine(AppContext.BaseDirectory, thisAssembly + FileNameSuffixes.RuntimeConfigJson)); + args.Add(Path.Combine(AppContext.BaseDirectory, thisAssembly + ".runtimeconfig.json")); args.Add(Path.Combine(AppContext.BaseDirectory, "dotnet-watch.dll")); diff --git a/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/Scenario/WatchableApp.cs b/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/Scenario/WatchableApp.cs index 7e5dc8ee8e..797e17f640 100644 --- a/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/Scenario/WatchableApp.cs +++ b/test/Microsoft.DotNet.Watcher.Tools.FunctionalTests/Scenario/WatchableApp.cs @@ -1,12 +1,12 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.Extensions.Tools.Internal; using System; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; -using Microsoft.DotNet.Cli.Utils; using Xunit.Abstractions; namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests @@ -72,7 +72,7 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests var spec = new ProcessSpec { - Executable = new Muxer().MuxerPath, + Executable = DotNetMuxer.MuxerPathOrDefault(), Arguments = args, WorkingDirectory = SourceDirectory };