From ae05e8af1d37c99124ca5f76396ad6f7e31d5dd2 Mon Sep 17 00:00:00 2001 From: Krzysztof Wicher Date: Thu, 16 Feb 2017 14:18:23 -0800 Subject: [PATCH] remove parameterless constructor --- src/dotnet/commands/dotnet-build/Program.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/dotnet/commands/dotnet-build/Program.cs b/src/dotnet/commands/dotnet-build/Program.cs index 5a8f9e37a..b29348757 100644 --- a/src/dotnet/commands/dotnet-build/Program.cs +++ b/src/dotnet/commands/dotnet-build/Program.cs @@ -15,8 +15,6 @@ namespace Microsoft.DotNet.Tools.Build { private MSBuildForwardingApp _forwardingApp; - private BuildCommand() { } - public BuildCommand(IEnumerable msbuildArgs, string msbuildPath = null) { _forwardingApp = new MSBuildForwardingApp(msbuildArgs, msbuildPath); @@ -24,8 +22,6 @@ namespace Microsoft.DotNet.Tools.Build public static BuildCommand FromArgs(string[] args, string msbuildPath = null) { - var buildCommand = new BuildCommand(); - CommandLineApplication app = new CommandLineApplication(throwOnUnexpectedArg: false); app.Name = "dotnet build"; app.FullName = LocalizableStrings.AppFullName; @@ -48,9 +44,12 @@ namespace Microsoft.DotNet.Tools.Build CommandOption noDependenciesOption = app.Option("--no-dependencies", LocalizableStrings.NoDependenciesOptionDescription, CommandOptionType.NoValue); CommandOption verbosityOption = MSBuildForwardingApp.AddVerbosityOption(app); + List msbuildArgs = null; app.OnExecute(() => { - List msbuildArgs = new List(); + // this delayed initialization is here intentionally + // this code will not get run in some cases (i.e. --help) + msbuildArgs = new List(); if (!string.IsNullOrEmpty(projectArgument.Value)) { @@ -105,18 +104,16 @@ namespace Microsoft.DotNet.Tools.Build msbuildArgs.AddRange(app.RemainingArguments); - buildCommand._forwardingApp = new MSBuildForwardingApp(msbuildArgs, msbuildPath); - return 0; }); int exitCode = app.Execute(args); - if (buildCommand._forwardingApp == null) + if (msbuildArgs == null) { throw new CommandCreationException(exitCode); } - return buildCommand; + return new BuildCommand(msbuildArgs, msbuildPath); } public static int Run(string[] args)