Add warning MSB4280 when DOTNET_HOST_PATH is set to a directory#13091
Merged
JanProvaznik merged 8 commits intomainfrom Jan 23, 2026
Merged
Add warning MSB4280 when DOTNET_HOST_PATH is set to a directory#13091JanProvaznik merged 8 commits intomainfrom
JanProvaznik merged 8 commits intomainfrom
Conversation
Contributor
|
Hello @@copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo. |
Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add warning for incorrect DOTNET_HOST_PATH usage in MSBuild
Add warning MSB4280 when DOTNET_HOST_PATH is set to a directory
Jan 22, 2026
Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
This was referenced Mar 11, 2026
Closed
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Roslyn build tasks and other SDK tools rely on
DOTNET_HOST_PATHto locate the dotnet executable. When users set this variable to a directory path instead of a file path, builds fail with unhelpful error messages, making root cause difficult to identify.Changes Made
MSB4280inBuildManager.BeginBuildthat fires whenDOTNET_HOST_PATHpoints to a directoryExceptionHandling.IsIoRelatedException()pattern for graceful failure when checking the pathEnvironmentVariableValidator.csinsrc/Build/BackEnd/BuildManager/to centralize environment variable validation logic:ValidateEnvironmentVariables(ILoggingService)called from BuildManagerValidateDotnetHostPath)Example output:
Testing
DotnetHostPathDirectoryWarning: verifies warning when path is directoryDotnetHostPathFileNoWarning: verifies no warning when path is fileDotnetHostPathNotSetNoWarning: verifies no warning when unsetTests use shared test infrastructure (
_env,_buildManager,_parameters,_logger) for concise implementation.Notes
Validation uses
FileSystems.Default.DirectoryExists()to detect directories without introducing new filesystem abstractions. I/O exceptions are silently ignored since this validation is best-effort and should not cause build failures if the path cannot be checked.The
EnvironmentVariableValidatorarchitecture is intentionally separate from theTraitsclass because:ILoggingServiceaccessILoggingServicewhich is only available in the Build projectOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.