Use async main in dotnet-watch

This commit is contained in:
Nate McMaster 2017-07-13 11:53:52 -07:00
parent c5879dbed7
commit 76aa9b26fc
2 changed files with 14 additions and 8 deletions

View File

@ -3,6 +3,7 @@
<Import Project="..\..\build\common.props" /> <Import Project="..\..\build\common.props" />
<PropertyGroup> <PropertyGroup>
<LangVersion>7.1</LangVersion>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
<AssemblyName>dotnet-watch</AssemblyName> <AssemblyName>dotnet-watch</AssemblyName>
<OutputType>exe</OutputType> <OutputType>exe</OutputType>

View File

@ -31,15 +31,21 @@ namespace Microsoft.DotNet.Watcher
_reporter = CreateReporter(verbose: true, quiet: false, console: _console); _reporter = CreateReporter(verbose: true, quiet: false, console: _console);
} }
public static int Main(string[] args) public static async Task<int> Main(string[] args)
{ {
DebugHelper.HandleDebugSwitch(ref args); try
using (var program = new Program(PhysicalConsole.Singleton, Directory.GetCurrentDirectory()))
{ {
return program DebugHelper.HandleDebugSwitch(ref args);
.RunAsync(args) using (var program = new Program(PhysicalConsole.Singleton, Directory.GetCurrentDirectory()))
.GetAwaiter() {
.GetResult(); return await program.RunAsync(args);
}
}
catch (Exception ex)
{
Console.Error.WriteLine("Unexpected error:");
Console.Error.WriteLine(ex.ToString());
return 1;
} }
} }
@ -200,7 +206,6 @@ namespace Microsoft.DotNet.Watcher
private static IReporter CreateReporter(bool verbose, bool quiet, IConsole console) private static IReporter CreateReporter(bool verbose, bool quiet, IConsole console)
=> new PrefixConsoleReporter(console, verbose || CliContext.IsGlobalVerbose(), quiet); => new PrefixConsoleReporter(console, verbose || CliContext.IsGlobalVerbose(), quiet);
private string NormalizePath(string path) private string NormalizePath(string path)
{ {
if (path == null || Path.IsPathRooted(path)) if (path == null || Path.IsPathRooted(path))