/// <summary>
        /// Functions which actually does the save of the settings. Persists the changes to the launch settings
        /// file and configures IIS if needed.
        /// </summary>
        public async virtual System.Threading.Tasks.Task SaveLaunchSettings()
        {
            ILaunchSettingsProvider provider = GetDebugProfileProvider();

            if (EnvironmentVariables != null && EnvironmentVariables.Count > 0)
            {
                SelectedDebugProfile.MutableEnvironmentVariables = EnvironmentVariables.CreateDictionary();
            }
            else if (SelectedDebugProfile != null)
            {
                SelectedDebugProfile.MutableEnvironmentVariables = null;
            }
            var globalSettings = provider.CurrentSnapshot.GlobalSettings;
            await provider.UpdateAndSaveSettingsAsync(new LaunchSettings(DebugProfiles, globalSettings, SelectedDebugProfile != null ? SelectedDebugProfile.Name : null)).ConfigureAwait(false);
        }
        public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null)
        {
            ILaunchSettings launchSettings = await _launchSettingsProvider.WaitForFirstSnapshot();

            IWritableLaunchSettings writableLaunchSettings = launchSettings.ToWritableLaunchSettings();

            if (SetPropertyValue(propertyName, unevaluatedPropertyValue, writableLaunchSettings))
            {
                await _launchSettingsProvider.UpdateAndSaveSettingsAsync(writableLaunchSettings.ToLaunchSettings());
            }

            // We've intercepted the "set" operation and redirected it to the launch settings.
            // Return "null" to indicate that the value should _not_ be set in the project file
            // as well.
            return(null);
        }
        public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null)
        {
            ConfiguredProject?configuredProject = await _project.GetSuggestedConfiguredProjectAsync();

            IPropertyPagesCatalogProvider?catalogProvider = configuredProject?.Services.PropertyPagesCatalog;

            if (catalogProvider == null)
            {
                return(null);
            }

            IPropertyPagesCatalog catalog = await catalogProvider.GetCatalogAsync(PropertyPageContexts.Project);

            Rule?rule = catalog.GetSchema(unevaluatedPropertyValue);

            if (rule == null)
            {
                return(null);
            }

            if (rule.Metadata.TryGetValue("CommandName", out object pageCommandNameObj) &&
                pageCommandNameObj is string pageCommandName)
            {
                _projectThreadingService.RunAndForget(async() =>
                {
                    // Infinite timeout means this will not actually be null.
                    ILaunchSettings?launchSettings = await _launchSettingsProvider.WaitForFirstSnapshot(Timeout.Infinite);
                    Assumes.NotNull(launchSettings);

                    IWritableLaunchSettings writableLaunchSettings = launchSettings.ToWritableLaunchSettings();
                    IWritableLaunchProfile?activeProfile           = writableLaunchSettings.ActiveProfile;
                    if (activeProfile != null)
                    {
                        activeProfile.CommandName = pageCommandName;

                        await _launchSettingsProvider.UpdateAndSaveSettingsAsync(writableLaunchSettings.ToLaunchSettings());
                    }
                },
                                                      options: ForkOptions.HideLocks,
                                                      unconfiguredProject: _project);
            }

            return(null);
        }
Пример #4
0
        public virtual async Task SaveLaunchSettings()
        {
            ILaunchSettingsProvider provider = GetDebugProfileProvider();

            if (EnvironmentVariables != null && EnvironmentVariables.Count > 0 && SelectedDebugProfile != null)
            {
                SelectedDebugProfile.EnvironmentVariables.Clear();
                foreach (NameValuePair kvp in EnvironmentVariables)
                {
                    SelectedDebugProfile.EnvironmentVariables.Add(kvp.Name, kvp.Value);
                }
            }
            else if (SelectedDebugProfile != null)
            {
                SelectedDebugProfile.EnvironmentVariables.Clear();
            }

            await provider.UpdateAndSaveSettingsAsync(CurrentLaunchSettings.ToLaunchSettings());
        }
Пример #5
0
        /// <summary>
        /// Functions which actually does the save of the settings. Persists the changes to the launch settings
        /// file and configures IIS if needed.
        /// </summary>
        public async virtual System.Threading.Tasks.Task SaveLaunchSettings()
        {
            ILaunchSettingsProvider provider = GetDebugProfileProvider();

            if (EnvironmentVariables != null && EnvironmentVariables.Count > 0 && SelectedDebugProfile != null)
            {
                SelectedDebugProfile.EnvironmentVariables.Clear();
                foreach (var kvp in EnvironmentVariables)
                {
                    SelectedDebugProfile.EnvironmentVariables.Add(kvp.Name, kvp.Value);
                }
            }
            else if (SelectedDebugProfile != null)
            {
                SelectedDebugProfile.EnvironmentVariables.Clear();
            }

            await provider.UpdateAndSaveSettingsAsync(CurrentLaunchSettings.ToLaunchSettings()).ConfigureAwait(false);
        }
        public override Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null)
        {
            _projectThreadingService.RunAndForget(async() =>
            {
                ILaunchSettings launchSettings = await _launchSettingsProvider.WaitForFirstSnapshot(Timeout.Infinite);

                var writableLaunchSettings = launchSettings.ToWritableLaunchSettings();
                if (SetPropertyValue(propertyName, unevaluatedPropertyValue, writableLaunchSettings))
                {
                    await _launchSettingsProvider.UpdateAndSaveSettingsAsync(writableLaunchSettings.ToLaunchSettings());
                }
            },
                                                  options: ForkOptions.HideLocks,
                                                  unconfiguredProject: _project);

            // We've intercepted the "set" operation and redirected it to the launch settings.
            // Return "null" to indicate that the value should _not_ be set in the project file
            // as well.
            return(Task.FromResult <string?>(null));
        }