Use Microsoft.IO.Redist in Framework FileUtilities/NativeMethods on net472 (#13078)#13428
Open
sachinsharma3191 wants to merge 6 commits intodotnet:mainfrom
Open
Use Microsoft.IO.Redist in Framework FileUtilities/NativeMethods on net472 (#13078)#13428sachinsharma3191 wants to merge 6 commits intodotnet:mainfrom
sachinsharma3191 wants to merge 6 commits intodotnet:mainfrom
Conversation
Author
|
@dotnet-policy-service agree |
sachinsharma3191
added a commit
to sachinsharma3191/msbuild
that referenced
this pull request
Mar 22, 2026
sachinsharma3191
added a commit
to sachinsharma3191/msbuild
that referenced
this pull request
Mar 22, 2026
b5b1ffe to
72bfc27
Compare
…3078) Add Microsoft.IO.Redist to Microsoft.Build.Framework for net4* targets. FileUtilities.GetFullPath and NativeMethods.GetCurrentDirectory use Microsoft.IO.Path and Microsoft.IO.Directory when FEATURE_MSIOREDIST is set. Legacy Win32 GetCurrentDirectory/GetFullPathName are not enabled by default: the FEATURE_LEGACY_* compile constants are preserved only as comments in Directory.BeforeCommon.targets, while the DllImports and helpers remain available behind FEATURE_LEGACY_* preprocessor guards for opt-in builds. Adjust Framework unit tests with a NETFRAMEWORK gate for path-too-long expander cases.
72bfc27 to
96d5dfb
Compare
When Path.GetFullPath throws PathTooLongException, rethrow instead of falling back to Microsoft.IO.Path.GetFullPath. The latter may not throw for the same path, causing Regress451057_ExitGracefullyIfPathNameIsTooLong tests to fail (they expect the task to return false, not succeed with a long path). Made-with: Cursor
…ths as invalid - Paths with leading/trailing whitespace: Microsoft.IO.Path.GetFullPath may trim them, causing incorrect resolution. Treat as invalid (CanNotResolveHintPathWithSpace). - Paths >= 260 chars: GetFullPath throws PathTooLongException on legacy Windows. Treat as invalid so callers skip NormalizePath and handle gracefully (Regress314573_VeryLongPaths). Made-with: Cursor
b4db326 to
ccc36bd
Compare
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.
Summary
Addresses #13078 by replacing custom Win32
GetFullPath/GetCurrentDirectorypaths inMicrosoft.Build.Frameworkwith Microsoft.IO.Redist whenFEATURE_MSIOREDISTis enabled (net472).Changes
FEATURE_LEGACY_GETCURRENTDIRECTORYandFEATURE_LEGACY_GETFULLPATHfromDirectory.BeforeCommon.targetsfor all net4* targets.FileUtilities.GetFullPath: useNewPath.GetFullPathwhenFEATURE_MSIOREDIST; otherwiseSystem.IO.Path.GetFullPath.NativeMethods.GetCurrentDirectory: useMicrosoft.IO.Directory.GetCurrentDirectory()whenFEATURE_MSIOREDIST; remove unused kernel32 imports and Win32 helpers removed with the legacy path code.Microsoft.IO.Redistpackage reference toMicrosoft.Build.Framework.csproj(conditional onFeatureMSIORedist, consistent with other projects).FileUtilities_Testsexpectation aligned with non-legacy behavior; Expander path-too-long cases gated with#if NETFRAMEWORK.Notes
MSBuildTaskHost(net35) keeps its own utilities and is unchanged.Microsoft.Build.Frameworkbuilds fornet10.0/netstandard2.0locally; fullnet472+ tests should be run on Windows per repo guidance.Fixes #13078