Exemplo n.º 1
0
        public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null)
        {
            ConfigurationGeneral configuration = await _properties.GetConfigurationGeneralPropertiesAsync();

            ComplexTargetFramework storedValues = await GetStoredComplexTargetFrameworkAsync(configuration);

            if (storedValues.TargetFrameworkMoniker != null)
            {
                if (StringComparers.PropertyLiteralValues.Equals(propertyName, InterceptedTargetFrameworkProperty))
                {
                    storedValues.TargetFrameworkMoniker = unevaluatedPropertyValue;
                }
                else if (StringComparers.PropertyLiteralValues.Equals(propertyName, TargetPlatformProperty))
                {
                    if (unevaluatedPropertyValue != storedValues.TargetPlatformIdentifier)
                    {
                        storedValues.TargetPlatformIdentifier = unevaluatedPropertyValue;
                        await ResetPlatformPropertiesAsync(defaultProperties);
                    }
                }
                else if (StringComparers.PropertyLiteralValues.Equals(propertyName, TargetPlatformVersionProperty))
                {
                    storedValues.TargetPlatformVersion = unevaluatedPropertyValue;
                }
                await defaultProperties.SetPropertyValueAsync(TargetFrameworkProperty, await ComputeValueAsync(storedValues));
            }

            return(null);
        }
        private static async Task <ComplexTargetFramework> GetStoredComplexTargetFrameworkAsync(ConfigurationGeneral configuration)
        {
            ComplexTargetFramework storedValues = new ComplexTargetFramework
            {
                TargetFrameworkMoniker   = (string?)await configuration.TargetFrameworkMoniker.GetValueAsync(),
                TargetPlatformIdentifier = (string?)await configuration.TargetPlatformIdentifier.GetValueAsync(),
                TargetPlatformVersion    = (string?)await configuration.TargetPlatformVersion.GetValueAsync(),
                TargetFramework          = (string?)await configuration.TargetFramework.GetValueAsync()
            };

            return(storedValues);
        }