From 74229e57db589fac3d836e424966692629037d89 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Tue, 9 Jan 2018 11:10:29 -0800 Subject: [PATCH] Fix FunctionalTests on fresh system --- .gitignore | 1 + .../Scenario/ProjectToolScenario.cs | 7 +++-- .../dotnet-watch.FunctionalTests.csproj | 26 +++++++++++++++++++ .../MsBuildFileSetFactoryTest.cs | 25 +++++++++--------- .../Utilities/TemporaryDirectory.cs | 2 +- 5 files changed, 46 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index ddc5e01720..78ed833761 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ testWorkDir/ .dotnet/ global.json *.binlog +test/dotnet-watch.FunctionalTests/TestProjects/NuGet.config \ No newline at end of file diff --git a/test/dotnet-watch.FunctionalTests/Scenario/ProjectToolScenario.cs b/test/dotnet-watch.FunctionalTests/Scenario/ProjectToolScenario.cs index dc90313fab..a11310c6e9 100644 --- a/test/dotnet-watch.FunctionalTests/Scenario/ProjectToolScenario.cs +++ b/test/dotnet-watch.FunctionalTests/Scenario/ProjectToolScenario.cs @@ -35,7 +35,10 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests CreateTestDirectory(); } - public string TempFolder { get; } = Path.Combine(Path.GetDirectoryName(FindNugetConfig()), "testWorkDir", Guid.NewGuid().ToString("N")); + + public static string TestWorkFolder { get; } = Path.Combine(AppContext.BaseDirectory, "testWorkDir"); + + public string TempFolder { get; } = Path.Combine(TestWorkFolder, Guid.NewGuid().ToString("N")); public string WorkFolder { get; } @@ -154,7 +157,7 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests private static string FindNugetConfig() { - var currentDirPath = AppContext.BaseDirectory; + var currentDirPath = TestWorkFolder; string nugetConfigFile; while (true) diff --git a/test/dotnet-watch.FunctionalTests/dotnet-watch.FunctionalTests.csproj b/test/dotnet-watch.FunctionalTests/dotnet-watch.FunctionalTests.csproj index 04d8118bc1..5d97fcca6f 100644 --- a/test/dotnet-watch.FunctionalTests/dotnet-watch.FunctionalTests.csproj +++ b/test/dotnet-watch.FunctionalTests/dotnet-watch.FunctionalTests.csproj @@ -21,6 +21,32 @@ + + + $(MSBuildThisFileDirectory)/TestProjects/NuGet.config + + + + + + + + + + + + + + + + + + + diff --git a/test/dotnet-watch.Tests/MsBuildFileSetFactoryTest.cs b/test/dotnet-watch.Tests/MsBuildFileSetFactoryTest.cs index 572b021f80..c34111b239 100644 --- a/test/dotnet-watch.Tests/MsBuildFileSetFactoryTest.cs +++ b/test/dotnet-watch.Tests/MsBuildFileSetFactoryTest.cs @@ -83,6 +83,7 @@ namespace Microsoft.DotNet.Watcher.Tools.Tests .SubDir("src") .SubDir("Project1") .WithCSharpProject("Project1", out var target) + .WithProperty("BaseIntermediateOutputPath", "obj") .WithTargetFrameworks("netcoreapp1.0") .Dir() .WithFile("Program.cs") @@ -111,18 +112,18 @@ namespace Microsoft.DotNet.Watcher.Tools.Tests [Fact] public async Task MultiTfm() { - _tempDir - .SubDir("src") - .SubDir("Project1") - .WithCSharpProject("Project1", out var target) - .WithTargetFrameworks("netcoreapp1.0", "net451") - .WithProperty("EnableDefaultCompileItems", "false") - .WithItem("Compile", "Class1.netcore.cs", "'$(TargetFramework)'=='netcoreapp1.0'") - .WithItem("Compile", "Class1.desktop.cs", "'$(TargetFramework)'=='net451'") - .Dir() - .WithFile("Class1.netcore.cs") - .WithFile("Class1.desktop.cs") - .WithFile("Class1.notincluded.cs"); + _tempDir + .SubDir("src") + .SubDir("Project1") + .WithCSharpProject("Project1", out var target) + .WithTargetFrameworks("netcoreapp1.0", "net451") + .WithProperty("EnableDefaultCompileItems", "false") + .WithItem("Compile", "Class1.netcore.cs", "'$(TargetFramework)'=='netcoreapp1.0'") + .WithItem("Compile", "Class1.desktop.cs", "'$(TargetFramework)'=='net451'") + .Dir() + .WithFile("Class1.netcore.cs") + .WithFile("Class1.desktop.cs") + .WithFile("Class1.notincluded.cs"); var fileset = await GetFileSet(target); diff --git a/test/dotnet-watch.Tests/Utilities/TemporaryDirectory.cs b/test/dotnet-watch.Tests/Utilities/TemporaryDirectory.cs index 26f36ec5f0..692899817e 100644 --- a/test/dotnet-watch.Tests/Utilities/TemporaryDirectory.cs +++ b/test/dotnet-watch.Tests/Utilities/TemporaryDirectory.cs @@ -104,4 +104,4 @@ namespace Microsoft.DotNet.Watcher.Tools.Tests } } } -} \ No newline at end of file +}