コード例 #1
0
        public static PublishCommand FromArgs(string[] args, string msbuildPath = null)
        {
            DebugHelper.HandleDebugSwitch(ref args);

            var msbuildArgs = new List <string>();

            var parser = Parser.Instance;

            var parseResult = parser.ParseFrom("dotnet publish", args);

            parseResult.ShowHelpOrErrorIfAppropriate();

            msbuildArgs.Add("-target:Publish");

            if (parseResult.HasOption(PublishCommandParser.SelfContainedOption) &&
                parseResult.HasOption(PublishCommandParser.NoSelfContainedOption))
            {
                throw new GracefulException(LocalizableStrings.SelfContainAndNoSelfContainedConflict);
            }

            msbuildArgs.AddRange(parseResult.OptionValuesToBeForwarded(PublishCommandParser.GetCommand()));

            msbuildArgs.AddRange(parseResult.ValueForArgument <IEnumerable <string> >(PublishCommandParser.SlnOrProjectArgument) ?? Array.Empty <string>());

            bool noRestore = parseResult.HasOption(PublishCommandParser.NoRestoreOption) ||
                             parseResult.HasOption(PublishCommandParser.NoBuildOption);

            return(new PublishCommand(
                       msbuildArgs,
                       noRestore,
                       msbuildPath));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: vitek-karas/sdk
        public static PublishCommand FromParseResult(ParseResult parseResult, string msbuildPath = null)
        {
            parseResult.HandleDebugSwitch();

            var msbuildArgs = new List <string>();

            parseResult.ShowHelpOrErrorIfAppropriate();

            msbuildArgs.Add("-target:Publish");

            CommonOptions.ValidateSelfContainedOptions(parseResult.HasOption(PublishCommandParser.SelfContainedOption),
                                                       parseResult.HasOption(PublishCommandParser.NoSelfContainedOption));

            msbuildArgs.AddRange(parseResult.OptionValuesToBeForwarded(PublishCommandParser.GetCommand()));

            msbuildArgs.AddRange(parseResult.GetValueForArgument(PublishCommandParser.SlnOrProjectArgument) ?? Array.Empty <string>());

            bool noRestore = parseResult.HasOption(PublishCommandParser.NoRestoreOption) ||
                             parseResult.HasOption(PublishCommandParser.NoBuildOption);

            return(new PublishCommand(
                       msbuildArgs,
                       noRestore,
                       msbuildPath));
        }