Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only add VCToolsVersion to the fingerprint for vcxproj projects #95

Merged
merged 1 commit into from
Oct 22, 2024
Merged
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
14 changes: 11 additions & 3 deletions src/Common/Fingerprinting/FingerprintFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,18 @@ void AddSettingToFingerprint(IReadOnlyCollection<Glob>? patterns, string setting
entries.Add(CreateFingerprintEntry($"Targets: {targetList}"));

// If the VC toolchain changes, the node should rebuild.
string vcToolsVersion = nodeContext.ProjectInstance.GetPropertyValue("VCToolsVersion");
if (!string.IsNullOrEmpty(vcToolsVersion))
// This only applies to projects using MSVC, but the Developer Command Prompt and Visual Studio set it as an environment variable,
// making GetPropertyValue always return a value. To avoid projects which don't use MSVC from getting cache misses when the version
// changes, only apply this to vcxproj files. It's feasible but rare for other projects to use MSVC, so this is a compromise for better
// cache hits.
if (nodeContext.ProjectFileRelativePath.EndsWith(".vcxproj", StringComparison.OrdinalIgnoreCase)
|| nodeContext.ProjectFileRelativePath.EndsWith(".nativeproj", StringComparison.OrdinalIgnoreCase))
{
entries.Add(CreateFingerprintEntry($"VCToolsVersion: {vcToolsVersion}"));
string vcToolsVersion = nodeContext.ProjectInstance.GetPropertyValue("VCToolsVersion");
if (!string.IsNullOrEmpty(vcToolsVersion))
{
entries.Add(CreateFingerprintEntry($"VCToolsVersion: {vcToolsVersion}"));
}
}

// If the .NET SDK changes, the node should rebuild.
Expand Down