Skip to content

Commit 830d7bf

Browse files
test: strengthen migration checks test with exit code assertion and remove reserved MSBuildProjectDirectory override
1 parent ec42050 commit 830d7bf

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/ElectronNET.IntegrationTests/Tests/MigrationChecksTargetsTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,13 @@ await File.WriteAllTextAsync(
5959

6060
// Create a minimal csproj that only imports the migration checks targets.
6161
// We deliberately import just that one targets file to keep the build fast.
62+
// Note: MSBuildProjectDirectory is a reserved MSBuild property — it must not be
63+
// redefined manually. MSBuild sets it automatically to the csproj's folder (tempDir).
6264
var targetsPathEscaped = TargetsFilePath.Replace("'", "'");
6365
await File.WriteAllTextAsync(
6466
Path.Combine(tempDir, "TestApp.csproj"),
6567
$"""
6668
<Project>
67-
<PropertyGroup>
68-
<MSBuildProjectDirectory>{tempDir}</MSBuildProjectDirectory>
69-
</PropertyGroup>
7069
<Import Project="{targetsPathEscaped}" />
7170
<Target Name="Build" DependsOnTargets="ElectronMigrationChecks" />
7271
</Project>
@@ -75,7 +74,10 @@ await File.WriteAllTextAsync(
7574
// ACT — run the Build target
7675
var (exitCode, output) = await RunDotnetBuildAsync(tempDir);
7776

78-
// ASSERT — the build must not produce the MSB4185 "unavailable function" error
77+
// ASSERT — the build must succeed and must not produce MSB4185
78+
exitCode.Should().Be(0,
79+
$"the temporary MSBuild project should build successfully. Full build output:\n{output}");
80+
7981
output.Should().NotContain(
8082
"MSB4185",
8183
$"ReadAllLines must not be used as an MSBuild property function. " +

0 commit comments

Comments
 (0)