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)); }
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)); }