public override async Task <IImmutableDictionary <string, string> > GetGlobalPropertiesAsync(CancellationToken cancellationToken) { IImmutableDictionary <string, string> properties = Empty.PropertiesMap; // Check: // - if this is an implicitly-triggered build // - if there is a single startup project // - if this is the startup project in question // - if this is a cross targeting project, i.e. project configuration has a "TargetFramework" dimension // - if the option to prefer single-target builds is turned on if (_implicitlyTriggeredBuildState.IsImplicitlyTriggeredBuild && _implicitlyTriggeredBuildState.StartupProjectFullPaths.Length == 1 && StringComparers.Paths.Equals(_implicitlyTriggeredBuildState.StartupProjectFullPaths[0], _configuredProject.UnconfiguredProject.FullPath) && _configuredProject.ProjectConfiguration.IsCrossTargeting() && await _projectSystemOptions.GetPreferSingleTargetBuildsForStartupProjectsAsync(cancellationToken)) { // We only want to build this for the framework that we will launch. string?activeDebuggingFramework = await _activeDebugFrameworkServices.GetActiveDebuggingFrameworkPropertyAsync(); if (activeDebuggingFramework is not null) { properties = properties.Add(ConfigurationGeneral.TargetFrameworkProperty, activeDebuggingFramework); } } return(properties); }
/// <summary> /// Called by the base when one of our menu ids is queried for. If the index is /// is greater than the count we want to return false /// </summary> public override bool QueryStatusCommand(int cmdIndex, EventArgs e) { IActiveDebugFrameworkServices activeDebugFramework = StartupProjectHelper.GetExportFromSingleDotNetStartupProject <IActiveDebugFrameworkServices>(ProjectCapability.LaunchProfiles); if (activeDebugFramework != null) { // See if this project supports at least two runtimes List <string> frameworks = null; string activeFramework = null; ExecuteSynchronously(async() => { frameworks = await activeDebugFramework.GetProjectFrameworksAsync().ConfigureAwait(false); if (frameworks != null && frameworks.Count > 1 && cmdIndex < frameworks.Count) { // Only call this if we will need it down below. activeFramework = await activeDebugFramework.GetActiveDebuggingFrameworkPropertyAsync().ConfigureAwait(false); } }); if (frameworks == null || frameworks.Count < 2) { // Hide and disable the command Visible = false; Enabled = false; Checked = false; return(true); } else if (cmdIndex >= 0 && cmdIndex < frameworks.Count) { Text = frameworks[cmdIndex]; Visible = true; Enabled = true; // Get's a check if it matches the active one, or there is no active one in which case the first one is the active one Checked = (string.IsNullOrEmpty(activeFramework) && cmdIndex == 0) || string.Equals(frameworks[cmdIndex], activeFramework, StringComparison.Ordinal); MatchedCommandId = 0; return(true); } } return(false); }
public void QueryStatus() { IActiveDebugFrameworkServices activeDebugFramework = StartupProjectHelper.GetExportFromSingleDotNetStartupProject <IActiveDebugFrameworkServices>(ProjectCapability.LaunchProfiles); if (activeDebugFramework != null) { string activeFramework = null; List <string> frameworks = null; ExecuteSynchronously(async() => { frameworks = await activeDebugFramework.GetProjectFrameworksAsync(); if (frameworks != null && frameworks.Count > 1) { // Only get this if we will need it down below activeFramework = await activeDebugFramework.GetActiveDebuggingFrameworkPropertyAsync(); } }); if (frameworks != null && frameworks.Count > 1) { // If no active framework or the current active property doesn't match any of the frameworks, then // st it to the first one. if (!string.IsNullOrEmpty(activeFramework) && frameworks.Contains(activeFramework)) { Text = string.Format(VSResources.DebugFrameworkMenuText, activeFramework); } else { Text = string.Format(VSResources.DebugFrameworkMenuText, frameworks[0]); } Visible = true; Enabled = true; } } }