This repository has been archived by the owner on Apr 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Program.cs
64 lines (49 loc) · 2.05 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// 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.Collections.Generic;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools;
using Microsoft.DotNet.Tools.MSBuild;
using Parser = Microsoft.DotNet.Cli.Parser;
namespace Microsoft.DotNet.Tools.Publish
{
public class PublishCommand : RestoringCommand
{
private PublishCommand(
IEnumerable<string> msbuildArgs,
IEnumerable<string> userDefinedArguments,
IEnumerable<string> trailingArguments,
bool noRestore,
string msbuildPath = null)
: base(msbuildArgs, userDefinedArguments, trailingArguments, noRestore, msbuildPath)
{
}
public static PublishCommand FromArgs(string[] args, string msbuildPath = null)
{
DebugHelper.HandleDebugSwitch(ref args);
var msbuildArgs = new List<string>();
var parser = Parser.Instance;
var result = parser.ParseFrom("dotnet publish", args);
result.ShowHelpOrErrorIfAppropriate();
msbuildArgs.Add("-target:Publish");
var appliedPublishOption = result["dotnet"]["publish"];
msbuildArgs.AddRange(appliedPublishOption.OptionValuesToBeForwarded());
msbuildArgs.AddRange(appliedPublishOption.Arguments);
bool noRestore = appliedPublishOption.HasOption("--no-restore")
|| appliedPublishOption.HasOption("--no-build");
return new PublishCommand(
msbuildArgs,
appliedPublishOption.OptionValuesToBeForwarded(),
appliedPublishOption.Arguments,
noRestore,
msbuildPath);
}
public static int Run(string[] args)
{
DebugHelper.HandleDebugSwitch(ref args);
return FromArgs(args).Execute();
}
}
}