public int Execute(OnExecute execute, string[] args) { _app.OnExecute(() => { // Locate the project and get the name and full path ProjectPathValue = _projectArgument.Value; if (string.IsNullOrEmpty(ProjectPathValue)) { ProjectPathValue = Directory.GetCurrentDirectory(); } OutputValue = _outputOption.Value(); BuildBasePathValue = _buildBasePath.Value(); ConfigValue = _configurationOption.Value() ?? Constants.DefaultConfiguration; RuntimeValue = _runtimeOption.Value(); VersionSuffixValue = _versionSuffixOption.Value(); IsNativeValue = _nativeOption.HasValue(); ArchValue = _archOption.Value(); IlcArgsValue = _ilcArgsOption.HasValue() ? _ilcArgsOption.Values : Enumerable.Empty <string>(); IlcPathValue = _ilcPathOption.Value(); IlcSdkPathValue = _ilcSdkPathOption.Value(); AppDepSdkPathValue = _appDepSdkPathOption.Value(); IsCppModeValue = _cppModeOption.HasValue(); CppCompilerFlagsValue = _cppCompilerFlagsOption.Value(); IEnumerable <ProjectContext> contexts; // Set defaults based on the environment var settings = ProjectReaderSettings.ReadFromEnvironment(); if (!string.IsNullOrEmpty(VersionSuffixValue)) { settings.VersionSuffix = VersionSuffixValue; } if (_frameworkOption.HasValue()) { contexts = _frameworkOption.Values .Select(f => { return(ProjectContext.CreateBuilder(ProjectPathValue, NuGetFramework.Parse(f)) .WithReaderSettings(settings) .Build()); }); } else { if (!string.IsNullOrEmpty(OutputValue)) { throw new InvalidOperationException($"'{_frameworkOption.LongName}' is required when '{_outputOption.LongName}' is specified"); } else { contexts = ProjectContext.CreateContextForEachFramework(ProjectPathValue, settings); } } var success = execute(contexts.ToList(), this); return(success ? 0 : 1); }); return(_app.Execute(args)); }