public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null) { if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, IconAndManifestValue)) { _temporaryPropertyStorage.AddOrUpdatePropertyValue(ResourceSpecificationKindProperty, IconAndManifestValue); await defaultProperties.SaveValueIfCurrentlySetAsync(Win32ResourceMSBuildProperty, _temporaryPropertyStorage); await defaultProperties.DeletePropertyAsync(Win32ResourceMSBuildProperty); await defaultProperties.RestoreValueIfNotCurrentlySetAsync(ApplicationIconMSBuildProperty, _temporaryPropertyStorage, dimensionalConditions); await defaultProperties.RestoreValueIfNotCurrentlySetAsync(ApplicationManifestMSBuildProperty, _temporaryPropertyStorage, dimensionalConditions); } else if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, ResourceFileValue)) { _temporaryPropertyStorage.AddOrUpdatePropertyValue(ResourceSpecificationKindProperty, ResourceFileValue); await defaultProperties.SaveValueIfCurrentlySetAsync(ApplicationIconMSBuildProperty, _temporaryPropertyStorage); await defaultProperties.SaveValueIfCurrentlySetAsync(ApplicationManifestMSBuildProperty, _temporaryPropertyStorage); await defaultProperties.DeletePropertyAsync(ApplicationIconMSBuildProperty); await defaultProperties.DeletePropertyAsync(ApplicationManifestMSBuildProperty); await defaultProperties.RestoreValueIfNotCurrentlySetAsync(Win32ResourceMSBuildProperty, _temporaryPropertyStorage, dimensionalConditions); } 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); }
// TODO should the rule file generate property and enum value constants that we can use here instead of these string literals? public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null) { if (unevaluatedPropertyValue == "IconAndManifest") { await defaultProperties.DeletePropertyAsync("Win32Resource"); } else if (unevaluatedPropertyValue == "ResourceFile") { await defaultProperties.DeletePropertyAsync("ApplicationIcon"); await defaultProperties.DeletePropertyAsync("ApplicationManifest"); } return(null); }
public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null) { if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, ExpressionValue)) { _temporaryPropertyStorage.AddOrUpdatePropertyValue(PackageLicenseKindProperty, ExpressionValue); await defaultProperties.SaveValueIfCurrentlySetAsync(PackageLicenseFileMSBuildProperty, _temporaryPropertyStorage); await defaultProperties.DeletePropertyAsync(PackageLicenseFileMSBuildProperty); await defaultProperties.RestoreValueIfNotCurrentlySetAsync(PackageLicenseExpressionMSBuildProperty, _temporaryPropertyStorage, dimensionalConditions); await defaultProperties.RestoreValueIfNotCurrentlySetAsync(PackageRequireLicenseAcceptanceMSBuildProperty, _temporaryPropertyStorage, dimensionalConditions); } else if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, FileValue)) { _temporaryPropertyStorage.AddOrUpdatePropertyValue(PackageLicenseKindProperty, FileValue); await defaultProperties.SaveValueIfCurrentlySetAsync(PackageLicenseExpressionMSBuildProperty, _temporaryPropertyStorage); await defaultProperties.DeletePropertyAsync(PackageLicenseExpressionMSBuildProperty); await defaultProperties.RestoreValueIfNotCurrentlySetAsync(PackageLicenseFileMSBuildProperty, _temporaryPropertyStorage, dimensionalConditions); await defaultProperties.RestoreValueIfNotCurrentlySetAsync(PackageRequireLicenseAcceptanceMSBuildProperty, _temporaryPropertyStorage, dimensionalConditions); } else if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, NoneValue)) { _temporaryPropertyStorage.AddOrUpdatePropertyValue(PackageLicenseKindProperty, NoneValue); await defaultProperties.SaveValueIfCurrentlySetAsync(PackageLicenseFileMSBuildProperty, _temporaryPropertyStorage); await defaultProperties.SaveValueIfCurrentlySetAsync(PackageLicenseExpressionMSBuildProperty, _temporaryPropertyStorage); await defaultProperties.SaveValueIfCurrentlySetAsync(PackageRequireLicenseAcceptanceMSBuildProperty, _temporaryPropertyStorage); await defaultProperties.DeletePropertyAsync(PackageLicenseFileMSBuildProperty); await defaultProperties.DeletePropertyAsync(PackageLicenseExpressionMSBuildProperty); await defaultProperties.DeletePropertyAsync(PackageRequireLicenseAcceptanceMSBuildProperty); } return(null); }
public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null) { if (string.Equals(unevaluatedPropertyValue, NoneValue)) { await defaultProperties.DeletePropertyAsync(NeutralLanguagePropertyName); return(null); } return(unevaluatedPropertyValue); }
public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null) { if (bool.TryParse(unevaluatedPropertyValue, out bool value)) { if (!value) { await defaultProperties.DeletePropertyAsync("DocumentationFile"); } } return(null); }
// TODO should the rule file generate property and enum value constants that we can use here instead of these string literals? public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null) { if (unevaluatedPropertyValue == "Expression") { await defaultProperties.DeletePropertyAsync("PackageLicenseFile"); } else if (unevaluatedPropertyValue == "File") { await defaultProperties.DeletePropertyAsync("PackageLicenseExpression"); } else if (unevaluatedPropertyValue == "None") { await defaultProperties.DeletePropertyAsync("PackageLicenseFile"); await defaultProperties.DeletePropertyAsync("PackageLicenseExpression"); await defaultProperties.DeletePropertyAsync("PackageRequireLicenseAcceptance"); } return(null); }
public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null) { if (bool.TryParse(unevaluatedPropertyValue, out bool value)) { if (value) { // Move TargetFramework -> TargetFrameworks string?targetFramework = await defaultProperties.GetUnevaluatedPropertyValueAsync(TargetFrameworkProperty); if (!Strings.IsNullOrEmpty(targetFramework)) { await defaultProperties.SetPropertyValueAsync(TargetFrameworksProperty, targetFramework); await defaultProperties.DeletePropertyAsync(TargetFrameworkProperty); } } else { // Move TargetFrameworks -> TargetFramework // // Requires TargetFrameworks to contain a valid string string?targetFrameworks = await defaultProperties.GetUnevaluatedPropertyValueAsync(TargetFrameworksProperty); if (!Strings.IsNullOrEmpty(targetFrameworks)) { string?firstTargetFramework = new LazyStringSplit(targetFrameworks, ';').FirstOrDefault(); if (!Strings.IsNullOrEmpty(firstTargetFramework)) { await defaultProperties.SetPropertyValueAsync(TargetFrameworkProperty, firstTargetFramework); await defaultProperties.DeletePropertyAsync(TargetFrameworksProperty); } } } } return(null); }
public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null) { if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, "true")) { // When setting this to "true", remove WarningsAsErrors await defaultProperties.SaveValueIfCurrentlySetAsync(WarningsAsErrorsProperty, _temporaryPropertyStorage); await defaultProperties.DeletePropertyAsync(WarningsAsErrorsProperty, dimensionalConditions); await defaultProperties.RestoreValueIfNotCurrentlySetAsync(WarningsNotAsErrorsProperty, _temporaryPropertyStorage); } else { // When settings this to "false", remove WarningsNotAsErrors await defaultProperties.SaveValueIfCurrentlySetAsync(WarningsNotAsErrorsProperty, _temporaryPropertyStorage); await defaultProperties.DeletePropertyAsync(WarningsNotAsErrorsProperty, dimensionalConditions); await defaultProperties.RestoreValueIfNotCurrentlySetAsync(WarningsAsErrorsProperty, _temporaryPropertyStorage); } return(await base.OnSetPropertyValueAsync(propertyName, unevaluatedPropertyValue, defaultProperties, dimensionalConditions)); }
public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null) { if (bool.TryParse(unevaluatedPropertyValue, out bool value)) { if (!value) { await defaultProperties.SaveValueIfCurrentlySetAsync(DocumentationFileMSBuildProperty, _temporaryPropertyStorage); await defaultProperties.DeletePropertyAsync(DocumentationFileMSBuildProperty); } else { await defaultProperties.RestoreValueIfNotCurrentlySetAsync(DocumentationFileMSBuildProperty, _temporaryPropertyStorage); } } return(null); }
public override async Task <string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary <string, string>?dimensionalConditions = null) { if (!bool.TryParse(unevaluatedPropertyValue, out bool value)) { return(null); } // When true, remove WarningsAsErrors. Otherwise, remove WarningsNotAsErrors. string removePropertyName = value ? WarningsAsErrorsProperty : WarningsNotAsErrorsProperty; string restorePropertyName = value ? WarningsNotAsErrorsProperty : WarningsAsErrorsProperty; await defaultProperties.SaveValueIfCurrentlySetAsync(removePropertyName, _temporaryPropertyStorage); await defaultProperties.DeletePropertyAsync(removePropertyName, dimensionalConditions); await defaultProperties.RestoreValueIfNotCurrentlySetAsync(restorePropertyName, _temporaryPropertyStorage, dimensionalConditions); return(unevaluatedPropertyValue); }
private async Task <bool> TrySetPropertyAsync(string unevaluatedPropertyValue, IProjectProperties defaultProperties, ProjectRootElement projectXml) { var currentValue = await defaultProperties.GetUnevaluatedPropertyValueAsync(BuildEvent).ConfigureAwait(true); if (currentValue == null) { return(false); } if (OnlyWhitespaceCharacters(unevaluatedPropertyValue)) { await defaultProperties.DeletePropertyAsync(BuildEvent).ConfigureAwait(true); return(true); } await defaultProperties.SetPropertyValueAsync(BuildEvent, unevaluatedPropertyValue).ConfigureAwait(true); return(true); }
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); }
public virtual Task DeletePropertyAsync(string propertyName, IReadOnlyDictionary <string, string>?dimensionalConditions = null) => DelegatedProperties.DeletePropertyAsync(propertyName, dimensionalConditions);