forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
50 lines (37 loc) · 1.44 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.CommandLine;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Extensions;
using Microsoft.DotNet.Tools.MSBuild;
namespace Microsoft.DotNet.Tools.Clean;
public class CleanCommand : MSBuildForwardingApp
{
public CleanCommand(IEnumerable<string> msbuildArgs, string msbuildPath = null)
: base(msbuildArgs, msbuildPath)
{
}
public static CleanCommand FromArgs(string[] args, string msbuildPath = null)
{
var parser = Parser.Instance;
var result = parser.ParseFrom("dotnet clean", args);
return FromParseResult(result, msbuildPath);
}
public static CleanCommand FromParseResult(ParseResult result, string msbuildPath = null)
{
var msbuildArgs = new List<string>
{
"-verbosity:normal"
};
result.ShowHelpOrErrorIfAppropriate();
msbuildArgs.AddRange(result.GetValue(CleanCommandParser.SlnOrProjectArgument) ?? Array.Empty<string>());
msbuildArgs.Add("-target:Clean");
msbuildArgs.AddRange(result.OptionValuesToBeForwarded(CleanCommandParser.GetCommand()));
return new CleanCommand(msbuildArgs, msbuildPath);
}
public static int Run(ParseResult parseResult)
{
parseResult.HandleDebugSwitch();
return FromParseResult(parseResult).Execute();
}
}