/// <summary> /// Removes a platform from the project. /// </summary> /// <param name="unconfiguredProject">Unconfigured project for which the configuration change.</param> /// <param name="platformName">Name of the deleted platform.</param> /// <returns>A task for the async operation.</returns> private async Task OnPlatformDeletedAsync(UnconfiguredProject unconfiguredProject, string platformName) { string evaluatedPropertyValue = await GetPropertyValue(unconfiguredProject).ConfigureAwait(false); await ProjectXmlAccessor.ExecuteInWriteLock(msbuildProject => { BuildUtilities.RemovePropertyValue(msbuildProject, evaluatedPropertyValue, PropertyName, platformName); }).ConfigureAwait(false); }
/// <summary> /// Adds a configuration to the project. /// </summary> /// <param name="unconfiguredProject">Unconfigured project for which the configuration change.</param> /// <param name="configurationName">Name of the new configuration.</param> /// <returns>A task for the async operation.</returns> private async Task OnConfigurationAddedAsync(UnconfiguredProject unconfiguredProject, string configurationName) { string evaluatedPropertyValue = await GetPropertyValue(unconfiguredProject).ConfigureAwait(false); await ProjectXmlAccessor.ExecuteInWriteLock(msbuildProject => { BuildUtilities.AppendPropertyValue(msbuildProject, evaluatedPropertyValue, PropertyName, configurationName); }).ConfigureAwait(false); }
/// <summary> /// Renames an existing configuration in the project. /// </summary> /// <param name="project">Unconfigured project for which the configuration change.</param> /// <param name="oldName">Original name of the configuration.</param> /// <param name="newName">New name of the configuration.</param> /// <returns>A task for the async operation.</returns> private async Task OnConfigurationRenamedAsync(UnconfiguredProject project, string oldName, string newName) { string evaluatedPropertyValue = await GetPropertyValue(project).ConfigureAwait(false); await ProjectXmlAccessor.ExecuteInWriteLock(msbuildProject => { BuildUtilities.RenamePropertyValue(msbuildProject, evaluatedPropertyValue, PropertyName, oldName, newName); }).ConfigureAwait(false); }
protected override async Task <ImmutableArray <string> > GetOrderedPropertyValuesAsync(UnconfiguredProject project) { Requires.NotNull(project, nameof(project)); string targetFrameworksProperty = await ProjectXmlAccessor.GetEvaluatedPropertyValue(project, ConfigurationGeneral.TargetFrameworksProperty).ConfigureAwait(true); if (targetFrameworksProperty != null) { return(BuildUtilities.GetPropertyValues(targetFrameworksProperty)); } else { // If the project doesn't have a "TargetFrameworks" property, then this is not a cross-targeting project and we don't need a target framework dimension. return(ImmutableArray <string> .Empty); } }
private void UpdateDependenciesSnapshotAsync( ImmutableDictionary <ITargetFramework, IDependenciesChanges> changes, IProjectCatalogSnapshot catalogs, ITargetFramework activeTargetFramework) { DependenciesSnapshot newSnapshot; bool anyChanges = false; HashSet <string> projectItemSpecs = null; CommonServices.ThreadingService.JoinableTaskFactory.Run(async() => { projectItemSpecs = await ProjectXmlAccessor.GetProjectItems().ConfigureAwait(false); }); // Note: we are updating existing snapshot, not receivig a complete new one. Thus we must // ensure incremental updates are done in the correct order. This lock ensures that here. lock (_snapshotLock) { newSnapshot = DependenciesSnapshot.FromChanges( CommonServices.Project.FullPath, _currentSnapshot, changes, catalogs, activeTargetFramework, SnapshotFilters.Select(x => x.Value), SubTreeProviders.Select(x => x.Value), projectItemSpecs, out anyChanges); _currentSnapshot = newSnapshot; } if (anyChanges) { // avoid unnecessary tree updates ScheduleDependenciesUpdate(); } }