Skip to content

Commit 47d4222

Browse files
CopilotmarcpopMSFT
andcommitted
Fix failing tests caused by new file existence validation
Co-authored-by: marcpopMSFT <[email protected]>
1 parent de25601 commit 47d4222

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetRunInvocation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public GivenDotnetRunInvocation(ITestOutputHelper log)
2525
[InlineData(new string[] { "-p", "prop1=true" }, new string[] { "--property:prop1=true" })]
2626
[InlineData(new string[] { "-p", "prop1=true", "-p", "prop2=false" }, new string[] { "--property:prop1=true", "--property:prop2=false" })]
2727
[InlineData(new string[] { "-p:prop1=true;prop2=false" }, new string[] { "--property:prop1=true", "--property:prop2=false" })]
28-
[InlineData(new string[] { "-p", "MyProject.csproj", "-p:prop1=true" }, new string[] { "--property:prop1=true" })]
28+
[InlineData(new string[] { "-p", "HelloWorld.csproj", "-p:prop1=true" }, new string[] { "--property:prop1=true" })]
2929
[InlineData(new string[] { "--disable-build-servers" }, new string[] { "--property:UseRazorBuildServer=false", "--property:UseSharedCompilation=false", "/nodeReuse:false" })]
3030
public void MsbuildInvocationIsCorrect(string[] args, string[] expectedArgs)
3131
{

test/dotnet.Tests/CommandTests/Run/RunParserTests.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,23 @@ public RunParserTests(ITestOutputHelper output)
1717
[Fact]
1818
public void RunParserCanGetArgumentFromDoubleDash()
1919
{
20-
var runCommand = RunCommand.FromArgs(new[] { "--project", "foo.csproj", "--", "foo" });
21-
runCommand.Args.Single().Should().Be("foo");
20+
// Create a temporary project file to ensure file validation passes
21+
var tempDir = Path.GetTempPath();
22+
var projectPath = Path.Combine(tempDir, "foo.csproj");
23+
File.WriteAllText(projectPath, "<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework></PropertyGroup></Project>");
24+
25+
try
26+
{
27+
var runCommand = RunCommand.FromArgs(new[] { "--project", projectPath, "--", "foo" });
28+
runCommand.Args.Single().Should().Be("foo");
29+
}
30+
finally
31+
{
32+
if (File.Exists(projectPath))
33+
{
34+
File.Delete(projectPath);
35+
}
36+
}
2237
}
2338
}
2439
}

0 commit comments

Comments
 (0)