private bool TryResolveFramework( IEnumerable <NuGetFramework> availableFrameworks, out NuGetFramework resolvedFramework) { NuGetFramework framework; if (FrameworkOption.HasValue()) { var frameworkOptionValue = FrameworkOption.Value(); framework = NuGetFramework.Parse(frameworkOptionValue); if (!availableFrameworks.Contains(framework)) { ReportError( string.Format( CultureInfo.CurrentCulture, Resources.ProjectDoesNotSupportProvidedFramework, ProjectArgument.Value, frameworkOptionValue)); resolvedFramework = null; return(false); } } else { // Prioritize non-desktop frameworks since they have the option of not dispatching to resolve TagHelpers. framework = availableFrameworks.FirstOrDefault(f => !f.IsDesktop()) ?? availableFrameworks.First(); } resolvedFramework = framework; return(true); }
private bool TryResolveFramework( IEnumerable <NuGetFramework> availableFrameworks, out NuGetFramework resolvedFramework) { NuGetFramework framework; if (FrameworkOption.HasValue()) { var frameworkOptionValue = FrameworkOption.Value(); framework = NuGetFramework.Parse(frameworkOptionValue); if (!availableFrameworks.Contains(framework)) { ReportError( string.Format( CultureInfo.CurrentCulture, Resources.ProjectDoesNotSupportProvidedFramework, ProjectArgument.Value, frameworkOptionValue)); resolvedFramework = null; return(false); } } else { framework = availableFrameworks.First(); } resolvedFramework = framework; return(true); }
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 ProjectContext GetRuntimeContext() { var workspace = new BuildWorkspace(ProjectReaderSettings.ReadFromEnvironment()); var projectContext = workspace.GetProjectContext(ProjectPath, TargetFramework); if (projectContext == null) { Debug.Assert(FrameworkOption.HasValue()); throw new InvalidOperationException($"Project '{ProjectPath}' does not support framework: {FrameworkOption.Value()}"); } var runtimeContext = workspace.GetRuntimeContext( projectContext, RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers()); return(runtimeContext); }
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); }