protected override int OnExecute() { var projectFile = ProjectReader.GetProject(ProjectArgument.Value); var targetFrameworks = projectFile .GetTargetFrameworks() .Select(frameworkInformation => frameworkInformation.FrameworkName); NuGetFramework framework; if (!TryResolveFramework(targetFrameworks, out framework)) { // Could not resolve framework for dispatch. Error was reported, exit early. return(0); } var dispatchArgs = new List <string> { CommandName, AssemblyNamesArgument.Value, }; if (ProtocolOption.HasValue()) { dispatchArgs.Add("--protocol"); dispatchArgs.Add(ProtocolOption.Value()); } var dispatchCommand = DotnetToolDispatcher.CreateDispatchCommand( dispatchArgs, framework, ConfigurationOption.Value(), outputPath: null, buildBasePath: BuildBasePathOption.Value(), projectDirectory: projectFile.ProjectDirectory); using (var errorWriter = new StringWriter()) { var commandExitCode = dispatchCommand .ForwardStdErr(errorWriter) .ForwardStdOut() .Execute() .ExitCode; if (commandExitCode != 0) { ReportError( string.Format( CultureInfo.CurrentCulture, Resources.FailedToExecuteRazorTooling, errorWriter.ToString())); } return(0); } }
public Options(string[] args) { commandLineApplication = new CommandLineApplication(); SolutionOption = commandLineApplication.Option("-s|--solution", "[Mandatory] Solution file (*.sln) path", CommandOptionType.SingleValue); ProjectOption = commandLineApplication.Option("-p|--project", "[Optional] Project name", CommandOptionType.SingleValue); ConfigurationOption = commandLineApplication.Option("-c|--configuration", "[Optional] Solution configuration name (if defined filter only this configuration)", CommandOptionType.SingleValue); PlatformOption = commandLineApplication.Option("-l|--platform", "[Optional] Solution platform name (if defined filter only this patform)", CommandOptionType.SingleValue); OrderByPlatformOption = commandLineApplication.Option("-op|--orderByPlatform", "[Optional] Output ordered by platform", CommandOptionType.NoValue); HelpOption = commandLineApplication.Option("-h|--help", "Show help", CommandOptionType.NoValue); var res = commandLineApplication.Execute(args); Solution = SolutionOption.HasValue() ? SolutionOption.Value() : null; Project = ProjectOption.HasValue() ? ProjectOption.Value() : null; Configuration = ConfigurationOption.HasValue() ? ConfigurationOption.Value() : null; Platform = PlatformOption.HasValue() ? PlatformOption.Value() : null; }
private void ParseArguments() { ProjectPath = GetProjectPath(); Configuration = ConfigurationOption.Value() ?? DotNet.Cli.Utils.Constants.DefaultConfiguration; if (!FrameworkOption.HasValue()) { throw new Exception($"Option {FrameworkOption.Template} does not have a value."); } TargetFramework = NuGetFramework.Parse(FrameworkOption.Value()); if (!OutputPathOption.HasValue()) { throw new Exception($"Option {OutputPathOption.Template} does not have a value."); } OutputPath = OutputPathOption.Value(); }
private bool ParseArguments() { ProjectPath = GetProjectPath(Options.ProjectArgument.Value); Configuration = ConfigurationOption.Value() ?? DotNet.Cli.Utils.Constants.DefaultConfiguration; if (FrameworkOption.HasValue()) { TargetFramework = NuGetFramework.Parse(FrameworkOption.Value()); } if (!OutputPathOption.HasValue()) { Application.Error.WriteLine($"Option {OutputPathOption.Template} does not have a value."); return(false); } OutputPath = OutputPathOption.Value(); return(true); }