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); }
/// <summary> /// Sets the application manifest property /// </summary> public override async Task <string> OnSetPropertyValueAsync(string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string> dimensionalConditions = null) { string returnValue = null; // We treat NULL/empty value as reset to default and remove the two properties from the project. if (string.IsNullOrEmpty(unevaluatedPropertyValue) || string.Equals(unevaluatedPropertyValue, DefaultManifestValue, StringComparison.InvariantCultureIgnoreCase)) { await defaultProperties.DeletePropertyAsync(ApplicationManifestMSBuildProperty); await defaultProperties.DeletePropertyAsync(NoManifestMSBuildProperty); } else if (string.Equals(unevaluatedPropertyValue, NoManifestValue, StringComparison.InvariantCultureIgnoreCase)) { await defaultProperties.DeletePropertyAsync(ApplicationManifestMSBuildProperty); await defaultProperties.SetPropertyValueAsync(NoManifestMSBuildProperty, "true"); } else { await defaultProperties.DeletePropertyAsync(NoManifestMSBuildProperty); // If we can make the path relative to the project folder do so. Otherwise just use the given path. if (Path.IsPathRooted(unevaluatedPropertyValue) && PathHelper.TryMakeRelativeToProjectDirectory(_unconfiguredProject, unevaluatedPropertyValue, out string relativePath)) { returnValue = relativePath; } else { returnValue = unevaluatedPropertyValue; } } return(returnValue); }
/// <summary> /// Sets the application manifest kind property /// </summary> public override async Task <string?> OnSetPropertyValueAsync( string propertyName, string?unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null) { if (string.Equals(unevaluatedPropertyValue, DefaultManifestValue, StringComparison.InvariantCultureIgnoreCase)) { await SaveCurrentApplicationManifestValueAsync(defaultProperties); await defaultProperties.DeletePropertyAsync(ApplicationManifestMSBuildProperty); await defaultProperties.DeletePropertyAsync(NoManifestMSBuildProperty); } else if (string.Equals(unevaluatedPropertyValue, NoManifestValue, StringComparison.InvariantCultureIgnoreCase)) { await SaveCurrentApplicationManifestValueAsync(defaultProperties); await defaultProperties.DeletePropertyAsync(ApplicationManifestMSBuildProperty); await defaultProperties.SetPropertyValueAsync(NoManifestMSBuildProperty, "true"); } else if (string.Equals(unevaluatedPropertyValue, CustomManifestValue, StringComparison.InvariantCultureIgnoreCase)) { await RestoreApplicationManifestValueAsync(defaultProperties); await defaultProperties.DeletePropertyAsync(NoManifestMSBuildProperty); } // We don't want to store a value for this so return null. return(null); }
/// <summary> /// Sets the application manifest kind property /// </summary> public override async Task <string?> OnSetPropertyValueAsync( string propertyName, string?unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null) { if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, DefaultManifestValue)) { await defaultProperties.SaveValueIfCurrentlySetAsync(ApplicationManifestMSBuildProperty, _temporaryPropertyStorage); await defaultProperties.DeletePropertyAsync(ApplicationManifestMSBuildProperty); await defaultProperties.DeletePropertyAsync(NoManifestMSBuildProperty); } else if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, NoManifestValue)) { await defaultProperties.SaveValueIfCurrentlySetAsync(ApplicationManifestMSBuildProperty, _temporaryPropertyStorage); await defaultProperties.DeletePropertyAsync(ApplicationManifestMSBuildProperty); await defaultProperties.SetPropertyValueAsync(NoManifestMSBuildProperty, "true"); } else if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, CustomManifestValue)) { await defaultProperties.RestoreValueIfNotCurrentlySetAsync(ApplicationManifestMSBuildProperty, _temporaryPropertyStorage); await defaultProperties.DeletePropertyAsync(NoManifestMSBuildProperty); } // We don't want to store a value for this so return null. return(null); }
/// <summary> /// If the "ApplicationManifest" MSBuild property does not currently have a value /// then restore the previously saved value, if any. /// </summary> private async Task RestoreApplicationManifestValueAsync(IProjectProperties defaultProperties) { string?currentApplicationManifestPropertyValue = await defaultProperties.GetUnevaluatedPropertyValueAsync(ApplicationManifestMSBuildProperty); if (string.IsNullOrEmpty(currentApplicationManifestPropertyValue) && _temporaryPropertyStorage.GetPropertyValue(ApplicationManifestMSBuildProperty) is string previousValue) { await defaultProperties.SetPropertyValueAsync(ApplicationManifestMSBuildProperty, previousValue); } }
/// <summary> /// If <paramref name="propertyName"/> is not currently set restores the saved value, if any, from <paramref name="storage"/>. /// </summary> public static async Task RestoreValueIfNotCurrentlySetAsync(this IProjectProperties properties, string propertyName, ITemporaryPropertyStorage storage) { string?currentPropertyValue = await properties.GetUnevaluatedPropertyValueAsync(propertyName); if (string.IsNullOrEmpty(currentPropertyValue) && storage.GetPropertyValue(propertyName) is string previousValue) { await properties.SetPropertyValueAsync(propertyName, previousValue); } }
public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null) { if (bool.TryParse(unevaluatedPropertyValue, out bool isDisabled)) { string warningLevelValue = isDisabled ? "0" : "1"; await defaultProperties.SetPropertyValueAsync(WarningLevelPropertyName, warningLevelValue, dimensionalConditions); } return(null); }
public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null) { // If we can make the path relative to the project folder do so. Otherwise just use the given path. if (Path.IsPathRooted(unevaluatedPropertyValue) && PathHelper.TryMakeRelativeToProjectDirectory(_unconfiguredProject, unevaluatedPropertyValue, out string?relativePath)) { unevaluatedPropertyValue = relativePath; } await defaultProperties.SetPropertyValueAsync(ApplicationManifestMSBuildProperty, unevaluatedPropertyValue); return(null); }
public async Task <bool> TrySetPropertyAsync(string unevaluatedPropertyValue, IProjectProperties defaultProperties) { string?currentValue = await defaultProperties.GetUnevaluatedPropertyValueAsync(BuildEvent); if (currentValue == null) { return(false); } if (OnlyWhitespaceCharacters(unevaluatedPropertyValue)) { await defaultProperties.DeletePropertyAsync(BuildEvent); return(true); } await defaultProperties.SetPropertyValueAsync(BuildEvent, unevaluatedPropertyValue); return(true); }
private async Task SetPackagePropertyValueAsync(IProjectProperties metadata, string propertyName, string propertyValue) { await metadata.SetPropertyValueAsync( propertyName, propertyValue); }
private async Task SetWarningsAsErrorIdsAsync(ImmutableSortedSet <int> updatedWarningsAsErrorIds, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions) { string value = CreateIdList(updatedWarningsAsErrorIds); await defaultProperties.SetPropertyValueAsync(WarningsAsErrorsPropertyName, value, dimensionalConditions); }