-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Log SDK environment variable messages only when values differ #12918
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
Conversation
These log messages were cluttering the structured log viewer with repeated messages about DOTNET_HOST_PATH and other SDK environment variables. Since these messages report normal expected behavior and aren't actionable for users, they have been removed entirely. Co-authored-by: YuliiaKovalova <[email protected]>
The string resources SdkEnvironmentVariableAlreadySet, SdkEnvironmentVariableAlreadySetBySdk, and SdkEnvironmentVariableSet are no longer used after removing the log messages that referenced them. This removes them from Strings.resx and all localized .xlf files. Co-authored-by: YuliiaKovalova <[email protected]>
|
This removes the logging entirely, right? How do we know if/how the SdkResolvers had any impact on the overall evaluation - does the viewer still show them as Properties in the eval (I'd expect so)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR removes non-actionable log messages about SDK environment variable operations that were cluttering structured log viewers. The changes eliminate three LogComment calls from AddSdkResolvedEnvironmentVariable() and clean up the associated unused string resources from all localization files.
- Removed logging of SDK environment variable setting operations (already set as env var, already set by another SDK, and successful set)
- Cleaned up three unused string resources from
Strings.resxand all 13 localized.xlffiles
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Build/Instance/ProjectInstance.cs | Removed three LogComment calls from AddSdkResolvedEnvironmentVariable() method |
| src/Build/Resources/Strings.resx | Removed three unused string resource definitions |
| src/Build/Resources/xlf/Strings.cs.xlf | Removed Czech translations for the three unused string resources |
| src/Build/Resources/xlf/Strings.de.xlf | Removed German translations for the three unused string resources |
| src/Build/Resources/xlf/Strings.es.xlf | Removed Spanish translations for the three unused string resources |
| src/Build/Resources/xlf/Strings.fr.xlf | Removed French translations for the three unused string resources |
| src/Build/Resources/xlf/Strings.it.xlf | Removed Italian translations for the three unused string resources |
| src/Build/Resources/xlf/Strings.ja.xlf | Removed Japanese translations for the three unused string resources |
| src/Build/Resources/xlf/Strings.ko.xlf | Removed Korean translations for the three unused string resources |
| src/Build/Resources/xlf/Strings.pl.xlf | Removed Polish translations for the three unused string resources |
| src/Build/Resources/xlf/Strings.pt-BR.xlf | Removed Brazilian Portuguese translations for the three unused string resources |
| src/Build/Resources/xlf/Strings.ru.xlf | Removed Russian translations for the three unused string resources |
| src/Build/Resources/xlf/Strings.tr.xlf | Removed Turkish translations for the three unused string resources |
| src/Build/Resources/xlf/Strings.zh-Hans.xlf | Removed Simplified Chinese translations for the three unused string resources |
| src/Build/Resources/xlf/Strings.zh-Hant.xlf | Removed Traditional Chinese translations for the three unused string resources |
The changes are clean and well-executed. The functionality of tracking and setting SDK environment variables remains intact—only the logging has been removed. All string resources have been properly cleaned up from the main resource file and all 13 localization files consistently. No issues were found during the review.
rainersigwald
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I might favor keeping these messages only if the values differ, instead of dropping them entirely.
@copilot please take a look |
Per feedback from @rainersigwald, changed the logging behavior to only emit messages when an SDK attempts to set an environment variable to a different value than what's already set. This reduces noise while still alerting users to potential conflicts. Changes: - Modified AddSdkResolvedEnvironmentVariable to check if values differ before logging - Updated string resources to include both the attempted and existing values in the message - Restored string resources to Strings.resx and all xlf files with updated messages that show both values This addresses the original issue of duplicate messages cluttering logs while preserving diagnostic information about actual conflicts. Co-authored-by: YuliiaKovalova <[email protected]>
I've updated the implementation in commit 6571644 to only log messages when values differ. The new behavior:
This preserves diagnostic information about actual conflicts while eliminating noise from normal operations. |
Extracted the duplicated value comparison and logging logic from AddSdkResolvedEnvironmentVariable into a new helper method LogIfValueDiffers. This eliminates code duplication while maintaining the same functionality. Co-authored-by: YuliiaKovalova <[email protected]>

Context
Structured log viewer was cluttered with repeated non-actionable messages about SDK environment variables (e.g.,
DOTNET_HOST_PATH). These appeared for every project evaluation, reporting normal SDK behavior without providing value to users.Changes Made
Modified
ProjectInstance.AddSdkResolvedEnvironmentVariable()to only log messages when an SDK attempts to set an environment variable to a different value than what's already set:LogIfValueDiffersto improve code maintainabilityUpdated string resources in
Strings.resxand all 13 localized.xlffiles:SdkEnvironmentVariableAlreadySet: Now includes both attempted and existing values in the messageSdkEnvironmentVariableAlreadySetBySdk: Now includes both attempted and existing values in the messageSdkEnvironmentVariableSet(no longer logging successful sets)The underlying functionality is unchanged—environment variables are still tracked and set correctly, and properties remain visible in the structured log viewer.
Testing
Notes
This implementation balances two concerns:
The messages log at
MessageImportance.Lowto provide diagnostic information without being intrusive in normal builds. Code quality was improved by extracting duplicate logic into a reusable helper method.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.