зеркало из https://github.com/aspnet/RazorTooling.git
Add DebugHelper to make debugging easier
This commit is contained in:
Родитель
75c1a2a99d
Коммит
25a292ecfa
|
@ -0,0 +1,25 @@
|
|||
// 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.
|
||||
|
||||
#if DEBUG
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Design.Internal
|
||||
{
|
||||
public class DebugHelper
|
||||
{
|
||||
public static void HandleDebugSwitch(ref string[] args)
|
||||
{
|
||||
if (args.Length > 0 && string.Equals("--debug", args[0], StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
args = args.Skip(1).ToArray();
|
||||
Console.Error.WriteLine("Waiting for debugger to attach. Press ENTER to continue");
|
||||
Console.Error.WriteLine($"Process ID: {Process.GetCurrentProcess().Id}");
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Razor.Design.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Design
|
||||
{
|
||||
|
@ -14,6 +15,9 @@ namespace Microsoft.AspNetCore.Razor.Design
|
|||
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugHelper.HandleDebugSwitch(ref args);
|
||||
#endif
|
||||
var app = new RazorToolingApplication(ProgramType);
|
||||
|
||||
EnsureValidDispatchRecipient(ref args);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
@ -86,6 +87,14 @@ namespace Microsoft.AspNetCore.Razor.Tools.Internal
|
|||
dispatchArgs.Add(ProtocolOption.Value());
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
var commandLineArgs = Environment.GetCommandLineArgs();
|
||||
if (commandLineArgs.Length > 1 && commandLineArgs[1] == "--debug")
|
||||
{
|
||||
dispatchArgs.Insert(0, commandLineArgs[1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
var toolName = typeof(Design.Program).GetTypeInfo().Assembly.GetName().Name;
|
||||
var dispatchCommand = DotnetToolDispatcher.CreateDispatchCommand(
|
||||
dispatchArgs,
|
||||
|
@ -99,7 +108,11 @@ namespace Microsoft.AspNetCore.Razor.Tools.Internal
|
|||
using (var errorWriter = new StringWriter())
|
||||
{
|
||||
var commandExitCode = dispatchCommand
|
||||
#if DEBUG
|
||||
.ForwardStdErr(Console.Error)
|
||||
#else
|
||||
.ForwardStdErr(errorWriter)
|
||||
#endif
|
||||
.ForwardStdOut()
|
||||
.Execute()
|
||||
.ExitCode;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNetCore.Razor.Design;
|
||||
using Microsoft.AspNetCore.Razor.Design.Internal;
|
||||
using Microsoft.AspNetCore.Razor.Tools.Internal;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Tools
|
||||
|
@ -10,6 +11,9 @@ namespace Microsoft.AspNetCore.Razor.Tools
|
|||
{
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugHelper.HandleDebugSwitch(ref args);
|
||||
#endif
|
||||
var app = new RazorToolingApplication(typeof(Program));
|
||||
|
||||
ResolveTagHelpersCommandBase.Register<ResolveTagHelpersDispatchCommand>(app);
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Razor.Tools.Test.Infrastructure
|
|||
var outputWriter = new StringWriter();
|
||||
|
||||
var exitCode = command
|
||||
.ForwardStdErr(outputWriter)
|
||||
.ForwardStdErr(Console.Error)
|
||||
.ForwardStdOut(outputWriter)
|
||||
.WorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
|
|
Загрузка…
Ссылка в новой задаче