dotnet-installer/build_projects/Microsoft.DotNet.Cli.Build.Framework/DebugHelper.cs

30 lines
937 B
C#
Raw Normal View History

2016-02-02 18:04:50 +00:00
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Diagnostics;
using System.Linq;
namespace Microsoft.DotNet.Cli.Build.Framework
{
public static class DebugHelper
{
[Conditional("DEBUG")]
public static void HandleDebugSwitch(ref string[] args)
{
if (args.Length > 0 && string.Equals("--debug", args[0], StringComparison.OrdinalIgnoreCase))
{
args = args.Skip(1).ToArray();
WaitForDebugger();
}
}
private static void WaitForDebugger()
{
Console.WriteLine("Waiting for debugger to attach. Press ENTER to continue");
Console.WriteLine($"Process ID: {Process.GetCurrentProcess().Id}");
Console.ReadLine();
}
}
}