private async Task ResetSubscriptions() { // active configuration should be updated before resetting subscriptions await RefreshActiveConfigurationAsync().ConfigureAwait(false); _designTimeBuildSubscriptionLink?.Dispose(); var currentProjects = await _activeConfiguredProjectsProvider.GetActiveConfiguredProjectsAsync().ConfigureAwait(false); if (currentProjects.Any()) { var sourceLinkOptions = new StandardRuleDataflowLinkOptions { RuleNames = _designTimeBuildWatchedRules, PropagateCompletion = true }; var sourceBlocks = currentProjects.Select( cp => cp.Services.ProjectSubscription.JointRuleSource.SourceBlock.SyncLinkOptions <IProjectValueVersions>(sourceLinkOptions)); var target = new ActionBlock <Tuple <ImmutableList <IProjectValueVersions>, TIdentityDictionary> >(ProjectPropertyChangedAsync); var targetLinkOptions = new DataflowLinkOptions { PropagateCompletion = true }; _designTimeBuildSubscriptionLink = ProjectDataSources.SyncLinkTo(sourceBlocks.ToImmutableList(), target, targetLinkOptions); } }
public override async Task <string> OnGetEvaluatedPropertyValueAsync(string propertyName, string evaluatedPropertyValue, IProjectProperties defaultProperties) { ActiveConfiguredObjects <ConfiguredProject>?configuredProjects = await _projectProvider.GetActiveConfiguredProjectsAsync(); if (configuredProjects == null) { return(""); } var builder = PooledArray <string> .GetInstance(capacity : configuredProjects.Objects.Length); foreach (ConfiguredProject configuredProject in configuredProjects.Objects) { ProjectProperties projectProperties = configuredProject.Services.ExportProvider.GetExportedValue <ProjectProperties>(); ConfigurationGeneral configuration = await projectProperties.GetConfigurationGeneralPropertiesAsync(); string?currentPlatformMoniker = (string?)await configuration.TargetPlatformIdentifier.GetValueAsync(); string?currentPlatformVersion = (string?)await configuration.TargetPlatformVersion.GetValueAsync(); Assumes.NotNull(currentPlatformMoniker); builder.Add($"{ currentPlatformMoniker }, Version={ currentPlatformVersion }"); } return(string.Join(";", builder.ToArrayAndFree())); }
public override async Task <string> OnGetEvaluatedPropertyValueAsync(string evaluatedPropertyValue, IProjectProperties defaultProperties) { ActiveConfiguredObjects <ConfiguredProject> configuredProjects = await _projectProvider.GetActiveConfiguredProjectsAsync(); ImmutableArray <string> .Builder builder = ImmutableArray.CreateBuilder <string>(); foreach (ConfiguredProject configuredProject in configuredProjects.Objects) { ProjectProperties projectProperties = configuredProject.Services.ExportProvider.GetExportedValue <ProjectProperties>(); ConfigurationGeneral configuration = await projectProperties.GetConfigurationGeneralPropertiesAsync(); string currentTargetFrameworkMoniker = (string)await configuration.TargetFrameworkMoniker.GetValueAsync(); builder.Add(currentTargetFrameworkMoniker); } return(string.Join(";", builder.ToArray())); }
private async Task ResetSubscriptionsAsync() { // active configuration should be updated before resetting subscriptions await RefreshActiveConfigurationAsync().ConfigureAwait(false); _designTimeBuildSubscriptionLink?.Dispose(); var currentProjects = await _activeConfiguredProjectsProvider.GetActiveConfiguredProjectsAsync() .ConfigureAwait(false); if (currentProjects != null) { var sourceLinkOptions = new StandardRuleDataflowLinkOptions { RuleNames = s_designTimeBuildWatchedRules, PropagateCompletion = true }; var disposableBag = new DisposableBag(CancellationToken.None); // We are taking source blocks from multiple configured projects and creating a SyncLink to combine the sources. // The SyncLink will only publish data when the versions of the sources match. There is a problem with that. // The sources have some version components that will make this impossible to match across TFMs. We introduce a // intermediate block here that will remove those version components so that the synclink can actually sync versions. var sourceBlocks = currentProjects.Objects.Select( cp => { var sourceBlock = cp.Services.ProjectSubscription.JointRuleSource.SourceBlock; var versionDropper = CreateVersionDropperBlock(); disposableBag.AddDisposable(sourceBlock.LinkTo(versionDropper, sourceLinkOptions)); return(versionDropper.SyncLinkOptions <IProjectValueVersions>(sourceLinkOptions)); }); var target = new ActionBlock <Tuple <ImmutableList <IProjectValueVersions>, TIdentityDictionary> >(ProjectPropertyChangedAsync); var targetLinkOptions = new DataflowLinkOptions { PropagateCompletion = true }; disposableBag.AddDisposable(ProjectDataSources.SyncLinkTo(sourceBlocks.ToImmutableList(), target, targetLinkOptions)); _designTimeBuildSubscriptionLink = disposableBag; } }
public override async Task <string> OnGetEvaluatedPropertyValueAsync(string evaluatedPropertyValue, IProjectProperties defaultProperties) { ActiveConfiguredObjects <ConfiguredProject>?configuredProjects = await _projectProvider.GetActiveConfiguredProjectsAsync(); if (configuredProjects == null) { return(""); } var builder = PooledArray <string> .GetInstance(); foreach (ConfiguredProject configuredProject in configuredProjects.Objects) { ProjectProperties projectProperties = configuredProject.Services.ExportProvider.GetExportedValue <ProjectProperties>(); ConfigurationGeneral configuration = await projectProperties.GetConfigurationGeneralPropertiesAsync(); string currentTargetFrameworkMoniker = (string)await configuration.TargetFrameworkMoniker.GetValueAsync(); builder.Add(currentTargetFrameworkMoniker); } return(string.Join(";", builder.ToArrayAndFree())); }