Simplify watcher arguments by passing everything to dotnet
This commit is contained in:
parent
dc9feade5a
commit
63bbafdb1d
|
|
@ -29,8 +29,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AppWithDeps", "test\TestApp
|
|||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Dependency", "test\TestApps\Dependency\Dependency.xproj", "{2F48041A-F7D1-478F-9C38-D41F0F05E8CA}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Watcher.Tools.Tests", "test\Microsoft.DotNet.Watcher.Tools.Tests\Microsoft.DotNet.Watcher.Tools.Tests.xproj", "{2E2FE108-0EB7-48CE-BD52-147E90180090}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -65,10 +63,6 @@ Global
|
|||
{2F48041A-F7D1-478F-9C38-D41F0F05E8CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2F48041A-F7D1-478F-9C38-D41F0F05E8CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2F48041A-F7D1-478F-9C38-D41F0F05E8CA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2E2FE108-0EB7-48CE-BD52-147E90180090}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2E2FE108-0EB7-48CE-BD52-147E90180090}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2E2FE108-0EB7-48CE-BD52-147E90180090}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2E2FE108-0EB7-48CE-BD52-147E90180090}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -82,6 +76,5 @@ Global
|
|||
{2AB1A28B-2022-49EA-AF77-AC8A875915CC} = {2876B12E-5841-4792-85A8-2929AEE11885}
|
||||
{F7734E61-F510-41E0-AD15-301A64081CD1} = {2876B12E-5841-4792-85A8-2929AEE11885}
|
||||
{2F48041A-F7D1-478F-9C38-D41F0F05E8CA} = {2876B12E-5841-4792-85A8-2929AEE11885}
|
||||
{2E2FE108-0EB7-48CE-BD52-147E90180090} = {F5B382BC-258F-46E1-AC3D-10E5CCD55134}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
15
README.md
15
README.md
|
|
@ -21,16 +21,19 @@ Add `Microsoft.DotNet.Watcher.Tools` to the `tools` section of your `project.jso
|
|||
|
||||
### How To Use
|
||||
|
||||
```dotnet watch <watcher args> -- <app args>```
|
||||
dotnet watch [dotnet arguments]
|
||||
|
||||
- `dotnet watch` (runs the application without arguments)
|
||||
- `dotnet watch foo bar` (runs the application with the arguments `foo bar`)
|
||||
- `dotnet watch --exit-on-change -- foo bar` (runs the application with the arguments `foo bar`. In addition, it passes `--exit-on-change` to the watcher).
|
||||
- `dotnet watch --command test -- -parallel none` (runs `dotnet test` with the arguments `-parallel none`)
|
||||
Add `watch` after `dotnet` in the command that you want to run:
|
||||
|
||||
| What you want to run | Dotnet watch command |
|
||||
| ---------------------------------------------- | -------------------------------------------------------- |
|
||||
| dotnet run | dotnet **watch** run |
|
||||
| dotnet run --arg1 value1 | dotnet **watch** run --arg1 value |
|
||||
| dotnet run --framework net451 -- --arg1 value1 | dotnet **watch** run --framework net451 -- --arg1 value1 |
|
||||
| dotnet test | dotnet **watch** test |
|
||||
|
||||
AppVeyor: [](https://ci.appveyor.com/project/aspnetci/dnx-watch/branch/dev)
|
||||
|
||||
Travis: [](https://travis-ci.org/aspnet/dotnet-watch)
|
||||
|
||||
|
||||
This project is part of ASP.NET Core. You can find samples, documentation and getting started instructions for ASP.NET Core at the [Home](https://github.com/aspnet/home) repo.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
|
||||
var VERSION='0.1'
|
||||
var FULL_VERSION='0.1'
|
||||
var AUTHORS='Microsoft Open Technologies, Inc.'
|
||||
-BuildQuality = "preview1";
|
||||
|
||||
use-standard-lifecycle
|
||||
k-standard-goals
|
||||
var VERSION='0.1'
|
||||
var FULL_VERSION='0.1'
|
||||
var AUTHORS='Microsoft Open Technologies, Inc.'
|
||||
-BuildQuality = "preview1";
|
||||
|
||||
use-standard-lifecycle
|
||||
k-standard-goals
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.DotNet.Watcher.Core.Internal;
|
||||
|
|
@ -18,8 +19,6 @@ namespace Microsoft.DotNet.Watcher.Core
|
|||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public bool ExitOnChange { get; set; }
|
||||
|
||||
public DotNetWatcher(
|
||||
Func<IFileWatcher> fileWatcherFactory,
|
||||
Func<IProcessWatcher> processWatcherFactory,
|
||||
|
|
@ -34,32 +33,23 @@ namespace Microsoft.DotNet.Watcher.Core
|
|||
_logger = _loggerFactory.CreateLogger(nameof(DotNetWatcher));
|
||||
}
|
||||
|
||||
public async Task WatchAsync(string projectFile, string command, string[] dotnetArguments, string workingDir, CancellationToken cancellationToken)
|
||||
public async Task WatchAsync(string projectFile, string[] dotnetArguments, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(projectFile))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(projectFile));
|
||||
}
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(command));
|
||||
}
|
||||
if (dotnetArguments == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(dotnetArguments));
|
||||
}
|
||||
if (string.IsNullOrEmpty(workingDir))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(workingDir));
|
||||
}
|
||||
if (cancellationToken == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(cancellationToken));
|
||||
}
|
||||
|
||||
var fullDotnetArgs = new string[dotnetArguments.Length + 1];
|
||||
fullDotnetArgs[0] = command;
|
||||
|
||||
// If any argument has spaces then quote it because we're going to convert everything
|
||||
// to string
|
||||
for (var i = 0; i < dotnetArguments.Length; i++)
|
||||
{
|
||||
var arg = dotnetArguments[i];
|
||||
|
|
@ -72,12 +62,13 @@ namespace Microsoft.DotNet.Watcher.Core
|
|||
break;
|
||||
}
|
||||
}
|
||||
fullDotnetArgs[i + 1] = arg;
|
||||
dotnetArguments[i] = arg;
|
||||
}
|
||||
dotnetArguments = fullDotnetArgs;
|
||||
|
||||
var dotnetArgumentsAsString = string.Join(" ", dotnetArguments);
|
||||
|
||||
var workingDir = Path.GetDirectoryName(projectFile);
|
||||
|
||||
while (true)
|
||||
{
|
||||
await WaitForValidProjectJsonAsync(projectFile, cancellationToken);
|
||||
|
|
@ -116,11 +107,6 @@ namespace Microsoft.DotNet.Watcher.Core
|
|||
_logger.LogError($"dotnet exit code: {dotnetExitCode}");
|
||||
}
|
||||
|
||||
if (ExitOnChange)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Waiting for a file to change before restarting dotnet...");
|
||||
// Now wait for a file to change before restarting dotnet
|
||||
await WaitForProjectFileToChangeAsync(projectFile, cancellationToken);
|
||||
|
|
@ -130,11 +116,6 @@ namespace Microsoft.DotNet.Watcher.Core
|
|||
// This is a file watcher task
|
||||
string changedFile = fileWatchingTask.Result;
|
||||
_logger.LogInformation($"File changed: {fileWatchingTask.Result}");
|
||||
|
||||
if (ExitOnChange)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,14 +8,11 @@ using System.Threading.Tasks;
|
|||
using Microsoft.DotNet.Watcher.Core;
|
||||
using Microsoft.Extensions.CommandLineUtils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.Watcher.Tools
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
private const string AppArgumentSeparator = "--";
|
||||
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
|
||||
public Program()
|
||||
|
|
@ -35,120 +32,27 @@ namespace Microsoft.DotNet.Watcher.Tools
|
|||
ctrlCTokenSource.Cancel();
|
||||
ev.Cancel = false;
|
||||
};
|
||||
|
||||
string[] watchArgs, appArgs;
|
||||
SeparateWatchArguments(args, out watchArgs, out appArgs);
|
||||
|
||||
return new Program().MainInternal(watchArgs, appArgs, ctrlCTokenSource.Token);
|
||||
|
||||
return new Program().MainInternal(args, ctrlCTokenSource.Token);
|
||||
}
|
||||
}
|
||||
|
||||
// The argument separation rules are: if no "--" is encountered, all arguments are passed to the app being watched.
|
||||
// Unless, the argument is "--help", in which case the help for the watcher is being invoked and everything else is discarded.
|
||||
// To pass arguments to both the watcher and the app use "--" as separator.
|
||||
// To pass "--help" to the app being watched, you must use "--": dotnet watch -- --help
|
||||
internal static void SeparateWatchArguments(string[] args, out string[] watchArgs, out string[] appArgs)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
watchArgs = new string[0];
|
||||
appArgs = new string[0];
|
||||
return;
|
||||
}
|
||||
|
||||
// Special case "--help"
|
||||
if (args[0].Equals("--help", StringComparison.OrdinalIgnoreCase) ||
|
||||
args[0].Equals("-h", StringComparison.OrdinalIgnoreCase) ||
|
||||
args[0].Equals("-?", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
watchArgs = new string[] { args[0] };
|
||||
appArgs = new string[0];
|
||||
return;
|
||||
}
|
||||
|
||||
var separatorIndex = -1;
|
||||
for (var i = 0; i < args.Length; i++)
|
||||
{
|
||||
if (string.Equals(args[i], AppArgumentSeparator, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
separatorIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (separatorIndex == -1)
|
||||
{
|
||||
watchArgs = new string[0];
|
||||
appArgs = args;
|
||||
}
|
||||
else
|
||||
{
|
||||
watchArgs = new string[separatorIndex];
|
||||
Array.Copy(args, 0, watchArgs, 0, separatorIndex);
|
||||
|
||||
var appArgsLength = args.Length - separatorIndex - 1;
|
||||
appArgs = new string[appArgsLength];
|
||||
Array.Copy(args, separatorIndex + 1, appArgs, 0, appArgsLength);
|
||||
}
|
||||
}
|
||||
|
||||
private int MainInternal(string[] watchArgs, string[] appArgs, CancellationToken cancellationToken)
|
||||
private int MainInternal(string[] args, CancellationToken cancellationToken)
|
||||
{
|
||||
var app = new CommandLineApplication();
|
||||
app.Name = "dotnet-watch";
|
||||
app.FullName = "Microsoft dotnet File Watcher";
|
||||
|
||||
app.HelpOption("-?|-h|--help");
|
||||
|
||||
var commandArg = app.Option(
|
||||
"--command <COMMAND>",
|
||||
"Optional. The dotnet command to run. Default: 'run'.",
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var workingDirArg = app.Option(
|
||||
"--working-dir <DIR>",
|
||||
"Optional. The working directory. Default: project's directory.",
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var exitOnChangeArg = app.Option(
|
||||
"--exit-on-change",
|
||||
"Optional. The watcher will exit when a file change is detected instead of restarting the process. Default: not set.",
|
||||
CommandOptionType.NoValue);
|
||||
|
||||
|
||||
app.OnExecute(() =>
|
||||
{
|
||||
var projectToWatch = Path.Combine(Directory.GetCurrentDirectory(), ProjectModel.Project.FileName);
|
||||
|
||||
var command = commandArg.Value();
|
||||
if (!commandArg.HasValue())
|
||||
{
|
||||
// The default command is "run". In this case we always assume the arguments are passed to the application being run.
|
||||
// If you want a different behaviour for run you need to use --command and pass the full arguments
|
||||
// Run is special because it requires a "--" before the arguments being passed to the application,
|
||||
// so the two command below are equivalent and resolve to "dotnet run -- --foo":
|
||||
// 1. dotnet watch --foo
|
||||
// 2. dotnet watch --command run -- -- --foo (yes, there are two "--")
|
||||
if (appArgs.Length > 0)
|
||||
{
|
||||
var newAppArgs = new string[appArgs.Length + 1];
|
||||
newAppArgs[0] = AppArgumentSeparator;
|
||||
appArgs.CopyTo(newAppArgs, 1);
|
||||
appArgs = newAppArgs;
|
||||
}
|
||||
|
||||
command = "run";
|
||||
}
|
||||
|
||||
var workingDir = workingDirArg.HasValue() ?
|
||||
workingDirArg.Value() :
|
||||
Path.GetDirectoryName(projectToWatch);
|
||||
|
||||
var watcher = DotNetWatcher.CreateDefault(_loggerFactory);
|
||||
watcher.ExitOnChange = exitOnChangeArg.HasValue();
|
||||
|
||||
try
|
||||
{
|
||||
watcher.WatchAsync(projectToWatch, command, appArgs, workingDir, cancellationToken).Wait();
|
||||
watcher.WatchAsync(projectToWatch, args, cancellationToken).Wait();
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
|
|
@ -158,11 +62,20 @@ namespace Microsoft.DotNet.Watcher.Tools
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
return app.Execute(watchArgs);
|
||||
if (args == null ||
|
||||
args.Length == 0 ||
|
||||
args[0].Equals("--help", StringComparison.OrdinalIgnoreCase) ||
|
||||
args[0].Equals("-h", StringComparison.OrdinalIgnoreCase) ||
|
||||
args[0].Equals("-?", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
app.ShowHelp();
|
||||
return 1;
|
||||
}
|
||||
|
||||
return app.Execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
|
|||
// Wait for the process to start
|
||||
using (var wait = new WaitForFileToChange(StatusFile))
|
||||
{
|
||||
RunDotNetWatch(StatusFile, Path.Combine(_scenario.WorkFolder, AppWithDeps));
|
||||
RunDotNetWatch($"run {StatusFile}", Path.Combine(_scenario.WorkFolder, AppWithDeps));
|
||||
|
||||
wait.Wait(_defaultTimeout,
|
||||
expectedToChange: true,
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
|
|||
// Wait for the process to start
|
||||
using (var wait = new WaitForFileToChange(StartedFile))
|
||||
{
|
||||
RunDotNetWatch(StatusFile, Path.Combine(_scenario.WorkFolder, TestAppName));
|
||||
RunDotNetWatch($"run {StatusFile}", Path.Combine(_scenario.WorkFolder, TestAppName));
|
||||
|
||||
wait.Wait(_defaultTimeout,
|
||||
expectedToChange: true,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>16bade2f-1184-4518-8a70-b68a19d0805b</ProjectGuid>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
|
|||
// Wait for the process to start
|
||||
using (var wait = new WaitForFileToChange(scenario.StartedFile))
|
||||
{
|
||||
scenario.RunDotNetWatch($"{scenario.StatusFile} --no-exit");
|
||||
scenario.RunDotNetWatch($"run {scenario.StatusFile} --no-exit");
|
||||
|
||||
wait.Wait(_defaultTimeout,
|
||||
expectedToChange: true,
|
||||
|
|
@ -59,7 +59,7 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
|
|||
// Wait for the process to start
|
||||
using (var wait = new WaitForFileToChange(scenario.StartedFile))
|
||||
{
|
||||
scenario.RunDotNetWatch(scenario.StatusFile);
|
||||
scenario.RunDotNetWatch($"run {scenario.StatusFile}");
|
||||
|
||||
wait.Wait(_defaultTimeout,
|
||||
expectedToChange: true,
|
||||
|
|
@ -90,44 +90,6 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ExitOnChange()
|
||||
{
|
||||
using (var scenario = new NoDepsAppScenario())
|
||||
{
|
||||
// Wait for the process to start
|
||||
using (var wait = new WaitForFileToChange(scenario.StartedFile))
|
||||
{
|
||||
scenario.RunDotNetWatch($"--exit-on-change -- {scenario.StatusFile} --no-exit");
|
||||
|
||||
wait.Wait(_defaultTimeout,
|
||||
expectedToChange: true,
|
||||
errorMessage: $"File not created: {scenario.StartedFile}");
|
||||
}
|
||||
|
||||
// Change a file
|
||||
var fileToChange = Path.Combine(scenario.TestAppFolder, "Program.cs");
|
||||
var programCs = File.ReadAllText(fileToChange);
|
||||
File.WriteAllText(fileToChange, programCs);
|
||||
|
||||
Waiters.WaitForProcessToStop(
|
||||
scenario.WatcherProcess.Id,
|
||||
_defaultTimeout,
|
||||
expectedToStop: true,
|
||||
errorMessage: "The watcher did not stop");
|
||||
|
||||
// Check that the first child process is no longer running
|
||||
var ids = File.ReadAllLines(scenario.StatusFile);
|
||||
var firstProcessId = int.Parse(ids[0]);
|
||||
Waiters.WaitForProcessToStop(
|
||||
firstProcessId,
|
||||
TimeSpan.FromSeconds(1),
|
||||
expectedToStop: true,
|
||||
errorMessage: $"PID: {firstProcessId} is still alive");
|
||||
}
|
||||
}
|
||||
|
||||
private class NoDepsAppScenario : DotNetWatchScenario
|
||||
{
|
||||
private const string TestAppName = "NoDepsApp";
|
||||
|
|
|
|||
|
|
@ -1,95 +0,0 @@
|
|||
// 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 Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.Watcher.Tools.Tests
|
||||
{
|
||||
public class ArgumentSeparatorTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(new string[0],
|
||||
new string[0],
|
||||
new string[0])]
|
||||
[InlineData(new string[] { "--" },
|
||||
new string[0],
|
||||
new string[0])]
|
||||
[InlineData(new string[] { "--appArg1" },
|
||||
new string[0],
|
||||
new string[] { "--appArg1" })]
|
||||
[InlineData(new string[] { "--command", "test" },
|
||||
new string[0],
|
||||
new string[] { "--command", "test" })]
|
||||
[InlineData(new string[] { "--command", "test", "--" },
|
||||
new string[] { "--command", "test" },
|
||||
new string[0])]
|
||||
[InlineData(new string[] { "--command", "test", "--", "--appArg1", "arg1Value" },
|
||||
new string[] { "--command", "test" },
|
||||
new string[] { "--appArg1", "arg1Value" })]
|
||||
[InlineData(new string[] { "--", "--appArg1", "arg1Value" },
|
||||
new string[0],
|
||||
new string[] { "--appArg1", "arg1Value" })]
|
||||
[InlineData(new string[] { "--", "--" },
|
||||
new string[0],
|
||||
new string[] { "--" })]
|
||||
[InlineData(new string[] { "--", "--", "--" },
|
||||
new string[0],
|
||||
new string[] { "--", "--" })]
|
||||
[InlineData(new string[] { "--command", "run", "--", "--", "--appArg", "foo" },
|
||||
new string[] { "--command", "run" },
|
||||
new string[] { "--", "--appArg", "foo" })]
|
||||
[InlineData(new string[] { "--command", "run", "--", "-f", "net451", "--", "--appArg", "foo" },
|
||||
new string[] { "--command", "run" },
|
||||
new string[] { "-f", "net451", "--", "--appArg", "foo" })]
|
||||
public void SeparateWatchArguments(string[] args, string[] expectedWatchArgs, string[] expectedAppArgs)
|
||||
{
|
||||
SeparateWatchArgumentsTest(args, expectedWatchArgs, expectedAppArgs);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
// Help is special if it's the first argument
|
||||
[InlineData(new string[] { "--help" },
|
||||
new string[] { "--help" },
|
||||
new string[0])]
|
||||
[InlineData(new string[] { "-h" },
|
||||
new string[] { "-h" },
|
||||
new string[0])]
|
||||
[InlineData(new string[] { "-?" },
|
||||
new string[] { "-?" },
|
||||
new string[0])]
|
||||
[InlineData(new string[] { "--help", "--this-is-ignored" },
|
||||
new string[] { "--help" },
|
||||
new string[0])]
|
||||
[InlineData(new string[] { "--help", "--", "--this-is-ignored" },
|
||||
new string[] { "--help" },
|
||||
new string[0])]
|
||||
// But not otherwise
|
||||
[InlineData(new string[] { "--", "--help" },
|
||||
new string[0],
|
||||
new string[] { "--help" })]
|
||||
[InlineData(new string[] { "--foo", "--help" },
|
||||
new string[0],
|
||||
new string[] { "--foo", "--help" })]
|
||||
[InlineData(new string[] { "--foo", "--help" },
|
||||
new string[0],
|
||||
new string[] { "--foo", "--help" })]
|
||||
[InlineData(new string[] { "--foo", "--", "--help" },
|
||||
new string[] { "--foo" },
|
||||
new string[] { "--help" })]
|
||||
public void SeparateWatchArguments_Help(string[] args, string[] expectedWatchArgs, string[] expectedAppArgs)
|
||||
{
|
||||
SeparateWatchArgumentsTest(args, expectedWatchArgs, expectedAppArgs);
|
||||
}
|
||||
|
||||
private static void SeparateWatchArgumentsTest(string[] args, string[] expectedWatchArgs, string[] expectedAppArgs)
|
||||
{
|
||||
string[] actualWatchArgs;
|
||||
string[] actualAppArgs;
|
||||
|
||||
Program.SeparateWatchArguments(args, out actualWatchArgs, out actualAppArgs);
|
||||
|
||||
Assert.Equal(expectedWatchArgs, actualWatchArgs);
|
||||
Assert.Equal(expectedAppArgs, actualAppArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0.25123" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25123</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>2e2fe108-0eb7-48ce-bd52-147e90180090</ProjectGuid>
|
||||
<RootNamespace>Microsoft.DotNet.Watcher.Tools.Tests</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
"buildOptions": {
|
||||
"warningsAsErrors": true,
|
||||
"keyFile": "../../tools/Key.snk"
|
||||
},
|
||||
"dependencies": {
|
||||
"dotnet-test-xunit": "1.0.0-*",
|
||||
"Microsoft.DotNet.Watcher.Tools": "1.0.0-*",
|
||||
"NETStandard.Library": "1.5.0-*",
|
||||
"xunit": "2.1.0"
|
||||
},
|
||||
"frameworks": {
|
||||
"netcoreapp1.0": {
|
||||
"imports": [
|
||||
"portable-net451+win8",
|
||||
"dnxcore50"
|
||||
],
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"type": "platform",
|
||||
"version": "1.0.0-*"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"testRunner": "xunit"
|
||||
}
|
||||
|
|
@ -9,9 +9,8 @@
|
|||
<ProjectGuid>f7734e61-f510-41e0-ad15-301a64081cd1</ProjectGuid>
|
||||
<RootNamespace>AppWithDeps</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -9,9 +9,8 @@
|
|||
<ProjectGuid>2f48041a-f7d1-478f-9c38-d41f0f05e8ca</ProjectGuid>
|
||||
<RootNamespace>Dependency</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -9,9 +9,8 @@
|
|||
<ProjectGuid>2ab1a28b-2022-49ea-af77-ac8a875915cc</ProjectGuid>
|
||||
<RootNamespace>GlobbingApp</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -9,9 +9,8 @@
|
|||
<ProjectGuid>4f0d8a80-221f-4bcb-822e-44a0655f537e</ProjectGuid>
|
||||
<RootNamespace>NoDepsApp</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
Loading…
Reference in New Issue