Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/Build/Instance/ProjectInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1390,13 +1390,13 @@ public void AddSdkResolvedEnvironmentVariable(string name, string value)
// If the property has already been set as an environment variable, we do not overwrite it.
if (_environmentVariableProperties.Contains(name))
{
_loggingContext.LogComment(MessageImportance.Low, "SdkEnvironmentVariableAlreadySet", name, value);
LogIfValueDiffers(_environmentVariableProperties, name, value, "SdkEnvironmentVariableAlreadySet");
return;
}
// If another SDK already set it, we do not overwrite it.
else if (_sdkResolvedEnvironmentVariableProperties?.Contains(name) == true)
{
_loggingContext.LogComment(MessageImportance.Low, "SdkEnvironmentVariableAlreadySetBySdk", name, value);
LogIfValueDiffers(_sdkResolvedEnvironmentVariableProperties, name, value, "SdkEnvironmentVariableAlreadySetBySdk");
return;
}

Expand All @@ -1412,8 +1412,18 @@ public void AddSdkResolvedEnvironmentVariable(string name, string value)
((IEvaluatorData<ProjectPropertyInstance, ProjectItemInstance, ProjectMetadataInstance, ProjectItemDefinitionInstance>)this)
.SetProperty(name, value, isGlobalProperty: false, mayBeReserved: false, loggingContext: _loggingContext, isEnvironmentVariable: true, isCommandLineProperty: false);
}
}

_loggingContext.LogComment(MessageImportance.Low, "SdkEnvironmentVariableSet", name, value);
/// <summary>
/// Helper method to log a message if the attempted value differs from the existing value.
/// </summary>
private void LogIfValueDiffers(PropertyDictionary<ProjectPropertyInstance> propertyDictionary, string name, string attemptedValue, string messageResourceName)
{
ProjectPropertyInstance existingProperty = propertyDictionary.GetProperty(name);
if (existingProperty != null && !string.Equals(existingProperty.EvaluatedValue, attemptedValue, StringComparison.Ordinal))
{
_loggingContext.LogComment(MessageImportance.Low, messageResourceName, name, attemptedValue, existingProperty.EvaluatedValue);
}
}

/// <summary>
Expand Down
8 changes: 3 additions & 5 deletions src/Build/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1384,14 +1384,12 @@ Errors: {3}</value>
<comment>{StrBegin="MSB4238: "}</comment>
</data>
<data name="SdkEnvironmentVariableAlreadySet" xml:space="preserve">
<value>An SDK attempted to set the environment variable "{0}" to "{1}" but it was already set as an environment variable.</value>
<value>An SDK attempted to set the environment variable "{0}" to "{1}" but it was already set to "{2}" as an environment variable.</value>
</data>
<data name="SdkEnvironmentVariableAlreadySetBySdk" xml:space="preserve">
<value>An SDK attempted to set the environment variable "{0}" to "{1}" but it was already set by another SDK.</value>
</data>
<data name="SdkEnvironmentVariableSet" xml:space="preserve">
<value>An SDK attempted set the environment variable "{0}" to "{1}".</value>
<value>An SDK attempted to set the environment variable "{0}" to "{1}" but it was already set to "{2}" by another SDK.</value>
</data>

<data name="UnrecognizedParentElement" xml:space="preserve">
<value>MSB4189: &lt;{1}&gt; is not a valid child of the &lt;{0}&gt; element.</value>
<comment>{StrBegin="MSB4189: "}</comment>
Expand Down
14 changes: 5 additions & 9 deletions src/Build/Resources/xlf/Strings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions src/Build/Resources/xlf/Strings.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions src/Build/Resources/xlf/Strings.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions src/Build/Resources/xlf/Strings.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions src/Build/Resources/xlf/Strings.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions src/Build/Resources/xlf/Strings.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions src/Build/Resources/xlf/Strings.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions src/Build/Resources/xlf/Strings.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading