Remove dependency on Microsoft.DotNet.Cli.Utils from test project
This commit is contained in:
parent
67c540051b
commit
346dfe8fe0
|
|
@ -3,11 +3,10 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp1.0</TargetFramework>
|
||||
<AssemblyName>dotnet-watch</AssemblyName>
|
||||
<OutputType>Exe</OutputType>
|
||||
<OutputType>exe</OutputType>
|
||||
<Description>Command line tool to watch for source file changes during development and restart the dotnet command.</Description>
|
||||
<PackageTags>dotnet;watch</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="**\*.cs" />
|
||||
<Compile Include="..\..\shared\**\*.cs" />
|
||||
|
|
@ -15,7 +14,6 @@
|
|||
<EmbeddedResource Include="dotnetwatch.targets" LogicalName="dotnetwatch.targets" />
|
||||
<Content Include="toolassets\*.targets" CopyToOutputDirectory="PreserveNewest" Pack="true" PackagePath="%(Identity)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Restore this when https://github.com/NuGet/Home/issues/3683 is resolved -->
|
||||
<!--<PackageReference Include="Microsoft.Extensions.Process.Sources" Version="1.1.0-*" PrivateAssets="All" />-->
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
<Content Include="..\..\src\Microsoft.DotNet.Watcher.Tools\toolassets\DotNetWatchCommon.targets" Link="toolassets\DotNetWatchCommon.targets" CopyToOutputDirectory="PreserveNewest" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.DotNet.Watcher.Tools\Microsoft.DotNet.Watcher.Tools.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.DotNet.Watcher.Tools.Tests\Microsoft.DotNet.Watcher.Tools.Tests.csproj" />
|
||||
<PackageReference Include="Microsoft.DotNet.Cli.Utils" Version="1.0.0-preview4-004215" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="CleanTestProjects" BeforeTargets="CoreCompile;CopyFilesToOutputDirectory">
|
||||
|
|
|
|||
|
|
@ -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"));
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue