diff --git a/test/dotnet.Tests/CommandTests/Run/GivenDotnetRunThrowsAParseError.cs b/test/dotnet.Tests/CommandTests/Run/GivenDotnetRunThrowsAParseError.cs index 035c7e7b1444..5fbec527dfd3 100644 --- a/test/dotnet.Tests/CommandTests/Run/GivenDotnetRunThrowsAParseError.cs +++ b/test/dotnet.Tests/CommandTests/Run/GivenDotnetRunThrowsAParseError.cs @@ -12,9 +12,12 @@ public GivenDotnetRunThrowsAParseError(ITestOutputHelper log) : base(log) [Fact] public void ItFailsWithAnAppropriateErrorMessage() { + // Use a dedicated empty directory because file-based program support means that dotnet run will + // pick up stray .cs files from other tests. + var emptyDir = TestAssetsManager.CreateTestDirectory().Path; + new DotnetCommand(Log, "run") - // executing in a known path, with no project, is a sure way to get run to throw a parse error - .WithWorkingDirectory(Path.GetTempPath()) + .WithWorkingDirectory(emptyDir) .Execute("--", "1") .Should().Fail() .And.HaveStdErrContainingOnce("Couldn't find a project to run.");