Skip to content
Closed
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
39 changes: 28 additions & 11 deletions src/MSBuild/ValidateMSBuildPackageDependencyVersions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,38 @@ public override bool Execute()
string assemblyVersion = AssemblyName.GetAssemblyName(path).Version.ToString();
if (!version.Equals(assemblyVersion))
{
Log.LogError(
subcategory: null,
errorCode: null,
helpKeyword: null,
file: appConfigPath,
lineNumber: bindingRedirectLineNumber,
columnNumber: 0,
endLineNumber: 0,
endColumnNumber: 0,
message: $"Binding redirect for '{name}' redirects to a different version ({version}) than MSBuild ships ({assemblyVersion}).");

// Ensure that the binding redirect is to the GAC version, but
// we still ship the version we explicitly reference to let
// API consumers bind to it at runtime.
// See https://github.com/dotnet/msbuild/issues/6976.
if (String.Equals(name, "System.ValueTuple", StringComparison.OrdinalIgnoreCase) &&
String.Equals(version, "4.0.0.0") && String.Equals(assemblyVersion, "4.0.3.0"))
{
// foundSystemValueTuple = true;
}
else
{
Log.LogError(
subcategory: null,
errorCode: null,
helpKeyword: null,
file: appConfigPath,
lineNumber: bindingRedirectLineNumber,
columnNumber: 0,
endLineNumber: 0,
endColumnNumber: 0,
message: $"Binding redirect for '{name}' redirects to a different version ({version}) than MSBuild ships ({assemblyVersion}).");
}
}
}
}
}

// if (!foundSystemValueTuple)
// {
// Log.LogError("Binding redirect for 'System.ValueTuple' missing.");
// }
Comment on lines +117 to +120
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These commented-out lines are part of the unreachable System.ValueTuple validation logic. Since System.ValueTuple is in the assembliesToIgnore array on line 23, it's filtered out at line 84, making the special case handling on lines 90-98 unreachable. This validation check can never execute, so the commented-out code should be removed entirely.

Copilot uses AI. Check for mistakes.
Comment on lines +94 to +120
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This special case handling for System.ValueTuple is unreachable code. On line 23, "System.ValueTuple" is included in the assembliesToIgnore array, and on line 84, the code checks !assembliesToIgnore.Contains(name, StringComparer.OrdinalIgnoreCase) before entering this block. This means when name is "System.ValueTuple", the entire block (lines 86-112) is skipped, making this special case check on lines 94-98 impossible to reach. The original PR #13125 was correct to remove this as dead code.

Suggested change
if (String.Equals(name, "System.ValueTuple", StringComparison.OrdinalIgnoreCase) &&
String.Equals(version, "4.0.0.0") && String.Equals(assemblyVersion, "4.0.3.0"))
{
// foundSystemValueTuple = true;
}
else
{
Log.LogError(
subcategory: null,
errorCode: null,
helpKeyword: null,
file: appConfigPath,
lineNumber: bindingRedirectLineNumber,
columnNumber: 0,
endLineNumber: 0,
endColumnNumber: 0,
message: $"Binding redirect for '{name}' redirects to a different version ({version}) than MSBuild ships ({assemblyVersion}).");
}
}
}
}
}
// if (!foundSystemValueTuple)
// {
// Log.LogError("Binding redirect for 'System.ValueTuple' missing.");
// }
Log.LogError(
subcategory: null,
errorCode: null,
helpKeyword: null,
file: appConfigPath,
lineNumber: bindingRedirectLineNumber,
columnNumber: 0,
endLineNumber: 0,
endColumnNumber: 0,
message: $"Binding redirect for '{name}' redirects to a different version ({version}) than MSBuild ships ({assemblyVersion}).");
}
}
}
}

Copilot uses AI. Check for mistakes.

return !Log.HasLoggedErrors;
}
}
Expand Down
Loading