public async Task <(bool success, string value)> TryGetEvaluatedPropertyValueAsync(IProjectProperties defaultProperties) { string?unevaluatedPropertyValue = await defaultProperties.GetUnevaluatedPropertyValueAsync(BuildEvent); if (unevaluatedPropertyValue is null) { return(false, ""); } string evaluatedPropertyValue = await defaultProperties.GetEvaluatedPropertyValueAsync(BuildEvent); return(true, evaluatedPropertyValue); }
public async Task <string> GetPropertyAsync(ProjectRootElement projectXml, IProjectProperties defaultProperties) { // check if value already exists var unevaluatedPropertyValue = await defaultProperties.GetUnevaluatedPropertyValueAsync(BuildEvent).ConfigureAwait(true); if (unevaluatedPropertyValue != null) { return(unevaluatedPropertyValue); } // Check if build events can be found in targets return(GetFromTargets(projectXml)); }
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); }
/// <summary> /// Restores the saved value of <paramref name="propertyName"/>, if not defined in context, from <paramref name="storage"/>. /// </summary> public static async Task RestoreValueIfNotCurrentlySetAsync(this IProjectProperties properties, string propertyName, ITemporaryPropertyStorage storage, IReadOnlyDictionary <string, string>?dimensionalConditions = null) { if (storage.GetPropertyValue(propertyName) is string previousValue) { bool inherited = await properties.IsValueInheritedAsync(propertyName); string?currentPropertyValue = await properties.GetUnevaluatedPropertyValueAsync(propertyName); if (inherited || string.IsNullOrEmpty(currentPropertyValue)) { await properties.SetPropertyValueAsync(propertyName, previousValue, dimensionalConditions); } } }
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 <string?> GetUnevaluatedPropertyValueAsync(string propertyName) => DelegatedProperties.GetUnevaluatedPropertyValueAsync(propertyName);
public override async Task <string> OnGetUnevaluatedPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties) { return(await defaultProperties.GetUnevaluatedPropertyValueAsync(ApplicationManifestMSBuildProperty) ?? string.Empty); }
public override async Task <string> OnGetUnevaluatedPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties) { string?win32Resource = await defaultProperties.GetUnevaluatedPropertyValueAsync(Win32ResourceMSBuildProperty); return(ComputeValue(win32Resource)); }