[msbuild] Fix race condition when generating MSBStrings.Designer.cs#24826
[msbuild] Fix race condition when generating MSBStrings.Designer.cs#24826rolfbjarne merged 1 commit intomainfrom
Conversation
When the Xamarin.Localization.MSBuild project was changed to multi-target (netstandard2.0 + net10.0), both inner builds run in parallel and both try to generate MSBStrings.Designer.cs to the same path. One build may write the file while the other is compiling it, causing: CSC : error CS1504: Source file 'MSBStrings.Designer.cs' could not be opened -- Attempted to read past the end of the stream. Fix by directing StronglyTypedFileName to $(IntermediateOutputPath), which is per-TFM (obj/Debug/netstandard2.0/ vs obj/Debug/net10.0/), so each inner build generates its own copy without interfering with the other. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a build race in Xamarin.Localization.MSBuild after it became multi-targeted by ensuring each inner build generates its strongly-typed resource designer into a TFM-specific intermediate directory instead of a shared project path.
Changes:
- Redirect
MSBStrings.Designer.csgeneration to$(IntermediateOutputPath)to avoid parallel inner builds writing/reading the same file.
You can also share your feedback on Copilot code review. Take the survey.
✅ [CI Build #b8c1406] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #b8c1406] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ [CI Build #b8c1406] Build passed (Build macOS tests) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #b8c1406] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 156 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
When the Xamarin.Localization.MSBuild project was changed to multi-target (netstandard2.0 + net10.0), both inner builds run in parallel and both try to generate MSBStrings.Designer.cs to the same path. One build may write the file while the other is compiling it, causing:
Fix by directing StronglyTypedFileName to $(IntermediateOutputPath), which is per-TFM (obj/Debug/netstandard2.0/ vs obj/Debug/net10.0/), so each inner build generates its own copy without interfering with the other.