fix: replace ReadAllLines with ReadAllText in MigrationChecks.targets…#1062
Merged
GregorBiswanger merged 5 commits intodevelopfrom May 9, 2026
Merged
Conversation
…fixes #1035) System.IO.File::ReadAllLines is not available as an MSBuild property function on all platforms (e.g. macOS GitHub Actions), causing MSB4185. ReadAllText is universally supported by MSBuild and sufficient for the regex check that detects 'electron' references in a root package.json (ELECTRON008). The intermediate ItemGroup for line accumulation is no longer needed.
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes cross-platform MSBuild failure (MSB4185) by switching the migration check to use a universally supported MSBuild property function, and adds regression tests for issue #1035.
Changes:
- Replace
System.IO.File::ReadAllLinesusage withSystem.IO.File::ReadAllTextinElectronNET.MigrationChecks.targets. - Remove the intermediate
ItemGroupused to accumulate file lines. - Add integration tests to prevent regressions and validate no MSB4185 during a real
dotnet build.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/ElectronNET/build/ElectronNET.MigrationChecks.targets | Switches package.json reading to ReadAllText and simplifies the target. |
| src/ElectronNET.IntegrationTests/Tests/MigrationChecksTargetsTests.cs | Adds coverage to detect ReadAllLines usage and to ensure builds don’t emit MSB4185. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+76
to
+82
| var (exitCode, output) = await RunDotnetBuildAsync(tempDir); | ||
|
|
||
| // ASSERT — the build must not produce the MSB4185 "unavailable function" error | ||
| output.Should().NotContain( | ||
| "MSB4185", | ||
| $"ReadAllLines must not be used as an MSBuild property function. " + | ||
| $"Full build output:\n{output}"); |
Comment on lines
+62
to
+73
| var targetsPathEscaped = TargetsFilePath.Replace("'", "'"); | ||
| await File.WriteAllTextAsync( | ||
| Path.Combine(tempDir, "TestApp.csproj"), | ||
| $""" | ||
| <Project> | ||
| <PropertyGroup> | ||
| <MSBuildProjectDirectory>{tempDir}</MSBuildProjectDirectory> | ||
| </PropertyGroup> | ||
| <Import Project="{targetsPathEscaped}" /> | ||
| <Target Name="Build" DependsOnTargets="ElectronMigrationChecks" /> | ||
| </Project> | ||
| """); |
Comment on lines
+67
to
+69
| <PropertyGroup> | ||
| <MSBuildProjectDirectory>{tempDir}</MSBuildProjectDirectory> | ||
| </PropertyGroup> |
Comment on lines
+15
to
+19
| private static readonly string TargetsFilePath = Path.GetFullPath( | ||
| Path.Combine( | ||
| AppContext.BaseDirectory, | ||
| "..", "..", "..", "..", "..", | ||
| "ElectronNET", "build", "ElectronNET.MigrationChecks.targets")); |
…emove reserved MSBuildProjectDirectory override
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.
… (fixes #1035)
System.IO.File::ReadAllLines is not available as an MSBuild property function on all platforms (e.g. macOS GitHub Actions), causing MSB4185.
ReadAllText is universally supported by MSBuild and sufficient for the regex check that detects 'electron' references in a root package.json (ELECTRON008). The intermediate ItemGroup for line accumulation is no longer needed.