From 13da2131835ca951d12900cce3edefe1fb9df12f Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Wed, 9 Aug 2017 22:30:20 -0700 Subject: [PATCH] Support new artifacts layout in tests and other build logic --- .../AppWithProjTool2Fx/App.csproj | 1 + .../AppWithProjTool2Fx/NuGet.Config | 6 ------ .../LibWithProjTool2Fx/Lib.csproj | 1 + .../LibWithProjTool2Fx/NuGet.Config | 6 ------ TestAssets/Directory.Build.props | 3 +++ TestAssets/TestPackages/NuGet.Config | 6 ------ .../11TestAppWith10CLIToolReferences.csproj | 1 + .../NuGet.Config | 6 ------ .../AppWithDirectDepWithOutputName.csproj | 1 + .../NuGet.Config | 8 -------- ...AppWithFallbackFolderToolDependency.csproj | 1 + .../NuGet.Config | 6 ------ .../DependencyContextFromTool.csproj | 1 + .../DependencyContextFromTool/NuGet.Config | 6 ------ .../TestAppWithProjDepTool/NuGet.Config | 6 ------ .../TestAppWithProjDepTool.csproj | 1 + build.proj | 2 +- build/BundledTemplates.proj | 1 + build/OutputDirectories.props | 2 +- build/Test.targets | 20 +++++++++---------- build/buildpipeline/security/syncAzure.proj | 1 + build/test/RunTest.proj | 7 ++++++- .../InvokeWithStage0.proj | 1 + dir.props | 4 ++++ src/redist/redist.csproj | 2 +- src/tool_fsharp/tool_fsc.csproj | 2 +- src/tool_roslyn/tool_roslyn.csproj | 2 +- .../ArgumentForwardingTests.csproj | 2 +- test/{dir.props => Directory.Build.props} | 2 +- .../Commands/TestCommand.cs | 3 +++ .../RepoDirectoriesProvider.cs | 13 ++++++++---- test/binding-redirects.Tests/NuGet.Config | 6 ------ .../binding-redirects.Tests.csproj | 1 + .../GivenThatIWantANewAppWithSpecifiedType.cs | 8 ++++++-- test/dotnet-new.Tests/dotnet-new.Tests.csproj | 5 +++++ test/dotnet.Tests/dotnet.Tests.csproj | 2 +- testAsset.props | 3 +++ 37 files changed, 67 insertions(+), 82 deletions(-) delete mode 100644 TestAssets/DesktopTestProjects/AppWithProjTool2Fx/NuGet.Config delete mode 100644 TestAssets/DesktopTestProjects/LibWithProjTool2Fx/NuGet.Config create mode 100644 TestAssets/Directory.Build.props delete mode 100644 TestAssets/TestPackages/NuGet.Config delete mode 100644 TestAssets/TestProjects/11TestAppWith10CLIToolReferences/NuGet.Config delete mode 100644 TestAssets/TestProjects/AppWithDirectDepWithOutputName/NuGet.Config delete mode 100644 TestAssets/TestProjects/AppWithFallbackFolderToolDependency/NuGet.Config delete mode 100644 TestAssets/TestProjects/DependencyContextFromTool/NuGet.Config delete mode 100644 TestAssets/TestProjects/TestAppWithProjDepTool/NuGet.Config create mode 100644 dir.props rename test/{dir.props => Directory.Build.props} (83%) delete mode 100644 test/binding-redirects.Tests/NuGet.Config diff --git a/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/App.csproj b/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/App.csproj index 0034bcf806..331a6e75f5 100644 --- a/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/App.csproj +++ b/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/App.csproj @@ -6,6 +6,7 @@ Exe $(AssetTargetFallback);portable-net45+win8;dnxcore50 win7-x64;win7-x86;osx.10.10-x64;osx.10.11-x64;ubuntu.14.04-x64;ubuntu.16.04-x64;ubuntu.16.10-x64;centos.7-x64;rhel.7.2-x64;debian.8-x64;fedora.24-x64;opensuse.42.1-x64 + $(TEST_PACKAGES) diff --git a/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/NuGet.Config b/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/NuGet.Config deleted file mode 100644 index b8e876fcb7..0000000000 --- a/TestAssets/DesktopTestProjects/AppWithProjTool2Fx/NuGet.Config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/Lib.csproj b/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/Lib.csproj index 1009df7ef1..81bd8b7676 100644 --- a/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/Lib.csproj +++ b/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/Lib.csproj @@ -3,6 +3,7 @@ netstandard1.6;net451 Library $(AssetTargetFallback);portable-net45+win8;dnxcore50;netcoreapp2.1 + $(TEST_PACKAGES) diff --git a/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/NuGet.Config b/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/NuGet.Config deleted file mode 100644 index b8e876fcb7..0000000000 --- a/TestAssets/DesktopTestProjects/LibWithProjTool2Fx/NuGet.Config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/TestAssets/Directory.Build.props b/TestAssets/Directory.Build.props new file mode 100644 index 0000000000..905549edcb --- /dev/null +++ b/TestAssets/Directory.Build.props @@ -0,0 +1,3 @@ + + + diff --git a/TestAssets/TestPackages/NuGet.Config b/TestAssets/TestPackages/NuGet.Config deleted file mode 100644 index 0750578cbd..0000000000 --- a/TestAssets/TestPackages/NuGet.Config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/TestAssets/TestProjects/11TestAppWith10CLIToolReferences/11TestAppWith10CLIToolReferences.csproj b/TestAssets/TestProjects/11TestAppWith10CLIToolReferences/11TestAppWith10CLIToolReferences.csproj index 6dd25f7f65..c15ae1a16e 100644 --- a/TestAssets/TestProjects/11TestAppWith10CLIToolReferences/11TestAppWith10CLIToolReferences.csproj +++ b/TestAssets/TestProjects/11TestAppWith10CLIToolReferences/11TestAppWith10CLIToolReferences.csproj @@ -4,6 +4,7 @@ Exe netcoreapp1.1 + $(TEST_PACKAGES) diff --git a/TestAssets/TestProjects/11TestAppWith10CLIToolReferences/NuGet.Config b/TestAssets/TestProjects/11TestAppWith10CLIToolReferences/NuGet.Config deleted file mode 100644 index b8e876fcb7..0000000000 --- a/TestAssets/TestProjects/11TestAppWith10CLIToolReferences/NuGet.Config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/TestAssets/TestProjects/AppWithDirectDepWithOutputName/AppWithDirectDepWithOutputName.csproj b/TestAssets/TestProjects/AppWithDirectDepWithOutputName/AppWithDirectDepWithOutputName.csproj index 7685e5e729..4eef160368 100755 --- a/TestAssets/TestProjects/AppWithDirectDepWithOutputName/AppWithDirectDepWithOutputName.csproj +++ b/TestAssets/TestProjects/AppWithDirectDepWithOutputName/AppWithDirectDepWithOutputName.csproj @@ -4,6 +4,7 @@ netcoreapp2.1 Exe + $(TEST_PACKAGES) diff --git a/TestAssets/TestProjects/AppWithDirectDepWithOutputName/NuGet.Config b/TestAssets/TestProjects/AppWithDirectDepWithOutputName/NuGet.Config deleted file mode 100644 index 4da396ac8f..0000000000 --- a/TestAssets/TestProjects/AppWithDirectDepWithOutputName/NuGet.Config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/TestAssets/TestProjects/AppWithFallbackFolderToolDependency/AppWithFallbackFolderToolDependency.csproj b/TestAssets/TestProjects/AppWithFallbackFolderToolDependency/AppWithFallbackFolderToolDependency.csproj index 28ef6634eb..76195b1cad 100755 --- a/TestAssets/TestProjects/AppWithFallbackFolderToolDependency/AppWithFallbackFolderToolDependency.csproj +++ b/TestAssets/TestProjects/AppWithFallbackFolderToolDependency/AppWithFallbackFolderToolDependency.csproj @@ -4,6 +4,7 @@ netcoreapp2.1 Exe + $(TEST_PACKAGES) diff --git a/TestAssets/TestProjects/AppWithFallbackFolderToolDependency/NuGet.Config b/TestAssets/TestProjects/AppWithFallbackFolderToolDependency/NuGet.Config deleted file mode 100644 index b8e876fcb7..0000000000 --- a/TestAssets/TestProjects/AppWithFallbackFolderToolDependency/NuGet.Config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj b/TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj index a3149221de..2de1535e20 100755 --- a/TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj +++ b/TestAssets/TestProjects/DependencyContextFromTool/DependencyContextFromTool.csproj @@ -8,6 +8,7 @@ Exe false $(AssetTargetFallback);dnxcore50;portable-net45+win8 + $(TEST_PACKAGES) diff --git a/TestAssets/TestProjects/DependencyContextFromTool/NuGet.Config b/TestAssets/TestProjects/DependencyContextFromTool/NuGet.Config deleted file mode 100644 index b8e876fcb7..0000000000 --- a/TestAssets/TestProjects/DependencyContextFromTool/NuGet.Config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/TestAssets/TestProjects/TestAppWithProjDepTool/NuGet.Config b/TestAssets/TestProjects/TestAppWithProjDepTool/NuGet.Config deleted file mode 100644 index b8e876fcb7..0000000000 --- a/TestAssets/TestProjects/TestAppWithProjDepTool/NuGet.Config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj b/TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj index b176613556..b4e6c98445 100644 --- a/TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj +++ b/TestAssets/TestProjects/TestAppWithProjDepTool/TestAppWithProjDepTool.csproj @@ -4,6 +4,7 @@ Exe netcoreapp2.1 + $(TEST_PACKAGES) diff --git a/build.proj b/build.proj index 3117ddb85c..2bbc62e48b 100644 --- a/build.proj +++ b/build.proj @@ -1,6 +1,6 @@ - + diff --git a/build/BundledTemplates.proj b/build/BundledTemplates.proj index f9d7301078..014f5bc92d 100644 --- a/build/BundledTemplates.proj +++ b/build/BundledTemplates.proj @@ -1,4 +1,5 @@ + $(BaseOutputDirectory)/AspRT $(IntermediateDirectory)/backwardsCompatibleSharedFrameworksPublish - $(BaseOutputDirectory)/testpackages/ + $(BaseOutputDirectory)/test/ $(OutputDirectory)/dotnet$(ExeExtension) $(IntermediateDirectory)/GeneratedMSBuildExtensions $(IntermediateDirectory)/MSBuildExtensionsLayout diff --git a/build/Test.targets b/build/Test.targets index 86cd8ea7e7..04c6a7f671 100644 --- a/build/Test.targets +++ b/build/Test.targets @@ -12,24 +12,20 @@ $(TestOutputDir)/results/ - - - - - - @(TestTaskEnvironmentVariables) - - + + + CLIBuildDll=$(CLIBuildDll); Configuration=$(Configuration); - EnvironmentVariables=$(RunTestEnvironmentVariables); + TestArtifactsDir=$(TestArtifactsDir); + TestPackagesDir=$(TestPackagesDir); TestProject=%(TestProjects.Identity); TestResultXmlDir=$(TestResultXmlDir); ToolPath=$(OutputDirectory); @@ -74,14 +70,16 @@ + ProjectPath="%(TestPackageProject.ProjectPath)" + AdditionalParameters="/p:RestoreAdditionalProjectSources=$(TestOutputDir)/packages" + /> + MsbuildArgs="%(TestPackageProject.MsbuildArgs) /p:SdkNuGetVersion=$(SdkNugetVersion) /p:RestoreAdditionalProjectSources=$(TestOutputDir)/packages" /> diff --git a/build/buildpipeline/security/syncAzure.proj b/build/buildpipeline/security/syncAzure.proj index 9388608875..45d7657ebd 100644 --- a/build/buildpipeline/security/syncAzure.proj +++ b/build/buildpipeline/security/syncAzure.proj @@ -1,5 +1,6 @@ + $(BuildToolsTaskDesktopDir)Microsoft.DotNet.Build.CloudTestTasks.dll diff --git a/build/test/RunTest.proj b/build/test/RunTest.proj index 8b1ec899f6..cff315a141 100644 --- a/build/test/RunTest.proj +++ b/build/test/RunTest.proj @@ -11,7 +11,12 @@ - + + + + + + diff --git a/dir.props b/dir.props new file mode 100644 index 0000000000..995f5e985a --- /dev/null +++ b/dir.props @@ -0,0 +1,4 @@ + + + + diff --git a/src/redist/redist.csproj b/src/redist/redist.csproj index 08f6d6ebbd..17d2febbc0 100644 --- a/src/redist/redist.csproj +++ b/src/redist/redist.csproj @@ -1,5 +1,5 @@  - + diff --git a/src/tool_fsharp/tool_fsc.csproj b/src/tool_fsharp/tool_fsc.csproj index 2738e5a7b1..68bfd019a1 100644 --- a/src/tool_fsharp/tool_fsc.csproj +++ b/src/tool_fsharp/tool_fsc.csproj @@ -1,5 +1,5 @@  - + $(CliVersionPrefix) diff --git a/src/tool_roslyn/tool_roslyn.csproj b/src/tool_roslyn/tool_roslyn.csproj index 7d79daa267..bc481ef14d 100644 --- a/src/tool_roslyn/tool_roslyn.csproj +++ b/src/tool_roslyn/tool_roslyn.csproj @@ -1,5 +1,5 @@  - + $(CliVersionPrefix) diff --git a/test/ArgumentForwardingTests/ArgumentForwardingTests.csproj b/test/ArgumentForwardingTests/ArgumentForwardingTests.csproj index 8d8441f26f..4c5a4fc067 100644 --- a/test/ArgumentForwardingTests/ArgumentForwardingTests.csproj +++ b/test/ArgumentForwardingTests/ArgumentForwardingTests.csproj @@ -24,7 +24,7 @@ - + diff --git a/test/dir.props b/test/Directory.Build.props similarity index 83% rename from test/dir.props rename to test/Directory.Build.props index 8d5c8cc421..406c4f8c1e 100644 --- a/test/dir.props +++ b/test/Directory.Build.props @@ -1,5 +1,5 @@ - + false diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs index 03ee56d6c2..b8f3ca9cca 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs @@ -238,6 +238,9 @@ private void AddEnvironmentVariablesTo(ProcessStartInfo psi) psi.Environment[item.Key] = item.Value; #endif } + + // Flow the TEST_PACKAGES environment variable to the child process + psi.Environment["TEST_PACKAGES"] = System.Environment.GetEnvironmentVariable("TEST_PACKAGES"); } private void AddWorkingDirectoryTo(ProcessStartInfo psi) diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/RepoDirectoriesProvider.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/RepoDirectoriesProvider.cs index dca694eafc..6f465a5b17 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/RepoDirectoriesProvider.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/RepoDirectoriesProvider.cs @@ -99,17 +99,22 @@ public RepoDirectoriesProvider( string corehostDummyPackages = null, string pjDotnet = null) { - _artifacts = artifacts ?? Path.Combine(RepoRoot, "artifacts", BuildRid); + _artifacts = artifacts ?? Path.Combine(RepoRoot, "artifacts", "stage2", BuildRid); _builtDotnet = builtDotnet ?? Path.Combine(_artifacts, "intermediate", "sharedFrameworkPublish"); _nugetPackages = nugetPackages ?? Path.Combine(RepoRoot, ".nuget", "packages"); _pjDotnet = pjDotnet ?? GetPjDotnetPath(); _stage2Sdk = Directory - .EnumerateDirectories(Path.Combine(_artifacts, "stage2", "sdk")) + .EnumerateDirectories(Path.Combine(_artifacts, "dotnet", "sdk")) .First(d => !d.Contains("NuGetFallbackFolder")); _stage2WithBackwardsCompatibleRuntimesDirectory = - Path.Combine(_artifacts, "stage2WithBackwardsCompatibleRuntimes"); - _testPackages = Path.Combine(RepoRoot, "artifacts", "testpackages", "packages"); + Path.Combine(_artifacts, "dotnetWithBackwardsCompatibleRuntimes"); + + _testPackages = Environment.GetEnvironmentVariable("TEST_PACKAGES"); + if (string.IsNullOrEmpty(_testPackages)) + { + throw new InvalidOperationException("TEST_PACKAGES environment variable not set"); + } } private string GetPjDotnetPath() diff --git a/test/binding-redirects.Tests/NuGet.Config b/test/binding-redirects.Tests/NuGet.Config deleted file mode 100644 index 507db39a69..0000000000 --- a/test/binding-redirects.Tests/NuGet.Config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/test/binding-redirects.Tests/binding-redirects.Tests.csproj b/test/binding-redirects.Tests/binding-redirects.Tests.csproj index 26c6e3040e..e34172c403 100644 --- a/test/binding-redirects.Tests/binding-redirects.Tests.csproj +++ b/test/binding-redirects.Tests/binding-redirects.Tests.csproj @@ -6,6 +6,7 @@ true binding-redirects.Tests $(AssetTargetFallback);dotnet5.4;portable-net451+win8 + $(TestOutputDir)/packages diff --git a/test/dotnet-new.Tests/GivenThatIWantANewAppWithSpecifiedType.cs b/test/dotnet-new.Tests/GivenThatIWantANewAppWithSpecifiedType.cs index fc412edef0..ac7a7308b4 100644 --- a/test/dotnet-new.Tests/GivenThatIWantANewAppWithSpecifiedType.cs +++ b/test/dotnet-new.Tests/GivenThatIWantANewAppWithSpecifiedType.cs @@ -51,8 +51,12 @@ public void TemplateRestoresAndBuildsWithoutWarnings( if (useNuGetConfigForAspNet) { - var configFile = new FileInfo(Path.Combine(rootPath, "..", "..", "..", "..", "..", "NuGet.tempaspnetpatch.config")); - File.Copy(configFile.FullName, Path.Combine(rootPath, "NuGet.Config")); + string resourceName = "dotnet-new.Tests.NuGet.tempaspnetpatch.config"; + using (Stream input = typeof(GivenThatIWantANewAppWithSpecifiedType).Assembly.GetManifestResourceStream(resourceName)) + using (Stream output = File.OpenWrite(Path.Combine(rootPath, "NuGet.Config"))) + { + input.CopyTo(output); + } } if (skipSpaWebpackSteps) diff --git a/test/dotnet-new.Tests/dotnet-new.Tests.csproj b/test/dotnet-new.Tests/dotnet-new.Tests.csproj index 1a855b363a..7a0ca3099a 100644 --- a/test/dotnet-new.Tests/dotnet-new.Tests.csproj +++ b/test/dotnet-new.Tests/dotnet-new.Tests.csproj @@ -7,6 +7,11 @@ $(AssetTargetFallback);dnxcore50;portable-net45+win8 + + + + + diff --git a/test/dotnet.Tests/dotnet.Tests.csproj b/test/dotnet.Tests/dotnet.Tests.csproj index f941c7d970..e47a3c5535 100644 --- a/test/dotnet.Tests/dotnet.Tests.csproj +++ b/test/dotnet.Tests/dotnet.Tests.csproj @@ -22,7 +22,7 @@ PreserveNewest PreserveNewest - + .version PreserveNewest diff --git a/testAsset.props b/testAsset.props index 4c05b30f1a..01455d290b 100644 --- a/testAsset.props +++ b/testAsset.props @@ -1,3 +1,6 @@ + + $(TEST_PACKAGES) +