protected async Task UpdateProfilesAsync(string updatedActiveProfileName) { try { // If the name of the new active profile wasn't provided we'll continue to use the // current one. if (updatedActiveProfileName == null) { ProjectDebugger props = await _commonProjectServices.ActiveConfiguredProjectProperties.GetProjectDebuggerPropertiesAsync(); if (await props.ActiveDebugProfile.GetValueAsync() is IEnumValue activeProfileVal) { updatedActiveProfileName = activeProfileVal.Name; } } LaunchSettingsData launchSettingData = await GetLaunchSettingsAsync(); // If there are no profiles, we will add a default profile to run the project. W/o it our debugger // won't be called on F5 and the user will see a poor error message if (launchSettingData.Profiles.Count == 0) { launchSettingData.Profiles.Add(new LaunchProfileData() { Name = Path.GetFileNameWithoutExtension(_commonProjectServices.Project.FullPath), CommandName = RunProjectCommandName }); } // If we have a previous snapshot merge in in-memory profiles ILaunchSettings prevSnapshot = CurrentSnapshot; if (prevSnapshot != null) { MergeExistingInMemoryProfiles(launchSettingData, prevSnapshot); MergeExistingInMemoryGlobalSettings(launchSettingData, prevSnapshot); } var newSnapshot = new LaunchSettings(launchSettingData, updatedActiveProfileName); FinishUpdate(newSnapshot); } catch (Exception ex) { // Errors are added as error list entries. We don't want to throw out of here // However, if we have never created a snapshot it means there is some error in the file and we want // to have the user see that, so we add a dummy profile which will bind to an existing debugger which will // display the error when run if (CurrentSnapshot == null) { var errorProfile = new LaunchProfile { Name = Resources.NoActionProfileName, CommandName = ErrorProfileCommandName, DoNotPersist = true, OtherSettings = ImmutableStringDictionary <object> .EmptyOrdinal.Add("ErrorString", ex.Message) }; var snapshot = new LaunchSettings(new[] { errorProfile }, null, errorProfile.Name); FinishUpdate(snapshot); } } }
/// <summary> /// <see cref="IActiveDebugFrameworkServices.GetActiveDebuggingFrameworkPropertyAsync"/> /// </summary> public async Task <string?> GetActiveDebuggingFrameworkPropertyAsync() { ProjectDebugger props = await _commonProjectServices.ActiveConfiguredProjectProperties.GetProjectDebuggerPropertiesAsync(); string?activeValue = await props.ActiveDebugFramework.GetValueAsync() as string; return(activeValue); }
protected async Task FinishUpdateAsync(ILaunchSettings newSnapshot, bool ensureProfileProperty) { CurrentSnapshot = newSnapshot; if (ensureProfileProperty) { ProjectDebugger props = await _commonProjectServices.ActiveConfiguredProjectProperties.GetProjectDebuggerPropertiesAsync(); if (await props.ActiveDebugProfile.GetValueAsync() is IEnumValue activeProfileVal) { if (newSnapshot.ActiveProfile?.Name != null && !string.Equals(newSnapshot.ActiveProfile?.Name, activeProfileVal.Name)) { await props.ActiveDebugProfile.SetValueAsync(newSnapshot.ActiveProfile.Name); } } } _broadcastBlock?.Post(newSnapshot); }
public async Task SetActiveProfileAsync(string profileName) { ProjectDebugger props = await _commonProjectServices.ActiveConfiguredProjectProperties.GetProjectDebuggerPropertiesAsync(); await props.ActiveDebugProfile.SetValueAsync(profileName); }
/// <summary> /// <see cref="IActiveDebugFrameworkServices.SetActiveDebuggingFrameworkPropertyAsync"/> /// </summary> public async Task SetActiveDebuggingFrameworkPropertyAsync(string activeFramework) { ProjectDebugger props = await _commonProjectServices.ActiveConfiguredProjectProperties.GetProjectDebuggerPropertiesAsync(); await props.ActiveDebugFramework.SetValueAsync(activeFramework); }