From cf116d619b0fec9502620ceea2e427ca03da8901 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 21 Mar 2019 09:28:44 -0700 Subject: [PATCH] Do not restore as part of test (dotnet/aspnetcore-tooling#350) \n\nCommit migrated from https://github.com/dotnet/aspnetcore-tooling/commit/84bc53671fe926c150509c797a6af9aefde82e80 --- .../BuildIncrementalismTest.cs | 4 +-- .../IntegrationTests/BuildIntegrationTest.cs | 2 +- .../BuildIntrospectionTest.cs | 4 +-- .../MSBuildIntegrationTestBase.cs | 6 ---- .../test/IntegrationTests/ProjectDirectory.cs | 29 ++++++++++++++----- .../PublishIntegrationTest.cs | 2 +- .../test/Microsoft.NET.Sdk.Razor.Test.csproj | 2 +- .../AppWithP2PReference.csproj | 6 ++-- .../ClassLibrary/ClassLibrary.csproj | 6 ++-- .../ClassLibrary2/ClassLibrary2.csproj | 6 ++-- .../ComponentApp/ComponentApp.csproj | 8 ++--- .../ComponentLibrary/ComponentLibrary.csproj | 8 ++--- .../test/testassets/Directory.Build.props | 1 + .../LargeProject/LargeProject.csproj | 6 ++-- .../MvcWithComponents.csproj | 6 ++-- .../RestoreTestProjects.csproj | 4 +++ .../testassets/SimpleMvc/SimpleMvc.csproj | 6 ++-- .../SimpleMvcFSharp/SimpleMvcFSharp.fsproj | 6 ++-- .../testassets/SimplePages/SimplePages.csproj | 6 ++-- 19 files changed, 65 insertions(+), 53 deletions(-) diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIncrementalismTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIncrementalismTest.cs index bdd22d4c08..fb0a5f0abe 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIncrementalismTest.cs +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIncrementalismTest.cs @@ -296,7 +296,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.FileExists(result, OutputPath, "ClassLibrary.Views.dll"); Assert.FileExists(result, OutputPath, "ClassLibrary.Views.pdb"); - result = await DotnetMSBuild(target: "Clean", "/p:BuildProjectReferences=false", suppressRestore: true); + result = await DotnetMSBuild(target: "Clean", "/p:BuildProjectReferences=false"); Assert.BuildPassed(result); Assert.FileDoesNotExist(result, OutputPath, "AppWithP2PReference.dll"); @@ -306,7 +306,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.FileDoesNotExist(result, OutputPath, "ClassLibrary.Views.pdb"); // dotnet msbuild /p:BuildProjectReferences=false - result = await DotnetMSBuild(target: default, "/p:BuildProjectReferences=false", suppressRestore: true); + result = await DotnetMSBuild(target: default, "/p:BuildProjectReferences=false"); Assert.BuildPassed(result); Assert.FileExists(result, OutputPath, "AppWithP2PReference.dll"); diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest.cs index ee8c87d889..04b7151649 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest.cs +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntegrationTest.cs @@ -539,7 +539,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests File.AppendAllText(class2Path, Environment.NewLine + "// Some changes"); // dotnet msbuild /p:BuildProjectReferences=false - result = await DotnetMSBuild(target: default, "/p:BuildProjectReferences=false", suppressRestore: true); + result = await DotnetMSBuild(target: default, "/p:BuildProjectReferences=false"); Assert.BuildPassed(result); } diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntrospectionTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntrospectionTest.cs index 986fecd991..eb7c93e3ff 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntrospectionTest.cs +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntrospectionTest.cs @@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.FileExists(result, OutputPath, "ClassLibrary.dll"); Assert.FileExists(result, OutputPath, "ClassLibrary.Views.dll"); - result = await DotnetMSBuild(target: "GetCopyToOutputDirectoryItems", "/t:_IntrospectGetCopyToOutputDirectoryItems /p:BuildProjectReferences=false", suppressRestore: true); + result = await DotnetMSBuild(target: "GetCopyToOutputDirectoryItems", "/t:_IntrospectGetCopyToOutputDirectoryItems /p:BuildProjectReferences=false"); Assert.BuildPassed(result); Assert.BuildOutputContainsLine(result, "AllItemsFullPathWithTargetPath: ClassLibrary.Views.dll"); Assert.BuildOutputContainsLine(result, "AllItemsFullPathWithTargetPath: ClassLibrary.Views.pdb"); @@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Directory.Delete(Path.Combine(Project.DirectoryPath, "Views"), recursive: true); // dotnet msbuild /p:BuildProjectReferences=false - result = await DotnetMSBuild(target: "GetCopyToOutputDirectoryItems", "/t:_IntrospectGetCopyToOutputDirectoryItems /p:BuildProjectReferences=false", suppressRestore: true); + result = await DotnetMSBuild(target: "GetCopyToOutputDirectoryItems", "/t:_IntrospectGetCopyToOutputDirectoryItems /p:BuildProjectReferences=false"); Assert.BuildOutputDoesNotContainLine(result, "AllItemsFullPathWithTargetPath: ClassLibrary.Views.dll"); Assert.BuildOutputDoesNotContainLine(result, "AllItemsFullPathWithTargetPath: ClassLibrary.Views.pdb"); diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/MSBuildIntegrationTestBase.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/MSBuildIntegrationTestBase.cs index 9ae25f1705..4803f4d46d 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/MSBuildIntegrationTestBase.cs +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/MSBuildIntegrationTestBase.cs @@ -57,7 +57,6 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests internal Task DotnetMSBuild( string target, string args = null, - bool suppressRestore = false, bool suppressTimeout = false, bool suppressBuildServer = false, string buildServerPipeName = null, @@ -76,11 +75,6 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests $"/p:MicrosoftNETCoreApp30PackageVersion={BuildVariables.MicrosoftNETCoreApp30PackageVersion}", }; - if (!suppressRestore) - { - buildArgumentList.Add("/restore"); - } - if (!suppressBuildServer) { buildArgumentList.Add($@"/p:_RazorBuildServerPipeName=""{buildServerPipeName ?? BuildServer.PipeName}"""); diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/ProjectDirectory.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/ProjectDirectory.cs index 6a73ab84cd..6f19052ebb 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/ProjectDirectory.cs +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/ProjectDirectory.cs @@ -86,11 +86,21 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests throw; } - void CopyDirectory(DirectoryInfo source, DirectoryInfo destination) + void CopyDirectory(DirectoryInfo source, DirectoryInfo destination, bool recursive = true) { + foreach (var file in source.EnumerateFiles()) + { + file.CopyTo(Path.Combine(destination.FullName, file.Name)); + } + + if (!recursive) + { + return; + } + foreach (var directory in source.EnumerateDirectories()) { - if (directory.Name == "bin" || directory.Name == "obj") + if (directory.Name == "bin") { // Just in case someone has opened the project in an IDE or built it. We don't want to copy // these folders. @@ -98,12 +108,15 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests } var created = destination.CreateSubdirectory(directory.Name); - CopyDirectory(directory, created); - } - - foreach (var file in source.EnumerateFiles()) - { - file.CopyTo(Path.Combine(destination.FullName, file.Name)); + if (directory.Name == "obj") + { + // Copy NuGet restore assets (viz all the files at the root of the obj directory, but stop there.) + CopyDirectory(directory, created, recursive: false); + } + else + { + CopyDirectory(directory, created); + } } } diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/PublishIntegrationTest.cs b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/PublishIntegrationTest.cs index eb19bd2b5b..ef50fffce3 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/PublishIntegrationTest.cs +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/PublishIntegrationTest.cs @@ -380,7 +380,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests Assert.FileExists(result, OutputPath, "ClassLibrary2.Views.dll"); // dotnet msbuild /t:Publish /p:BuildProjectReferences=false - result = await DotnetMSBuild(target: "Publish", "/p:BuildProjectReferences=false", suppressRestore: true); + result = await DotnetMSBuild(target: "Publish", "/p:BuildProjectReferences=false"); Assert.BuildPassed(result); diff --git a/src/Razor/Microsoft.NET.Sdk.Razor/test/Microsoft.NET.Sdk.Razor.Test.csproj b/src/Razor/Microsoft.NET.Sdk.Razor/test/Microsoft.NET.Sdk.Razor.Test.csproj index 8bda9b03d2..b1d8222aa7 100644 --- a/src/Razor/Microsoft.NET.Sdk.Razor/test/Microsoft.NET.Sdk.Razor.Test.csproj +++ b/src/Razor/Microsoft.NET.Sdk.Razor/test/Microsoft.NET.Sdk.Razor.Test.csproj @@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests - + diff --git a/src/Razor/test/testassets/AppWithP2PReference/AppWithP2PReference.csproj b/src/Razor/test/testassets/AppWithP2PReference/AppWithP2PReference.csproj index d85a5ebfb8..45907b402f 100644 --- a/src/Razor/test/testassets/AppWithP2PReference/AppWithP2PReference.csproj +++ b/src/Razor/test/testassets/AppWithP2PReference/AppWithP2PReference.csproj @@ -28,10 +28,10 @@ - + - - + $(RepositoryRoot)artifacts\bin\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\$(Configuration)\netstandard2.0\ + diff --git a/src/Razor/test/testassets/ClassLibrary/ClassLibrary.csproj b/src/Razor/test/testassets/ClassLibrary/ClassLibrary.csproj index caab60a992..4e4b461927 100644 --- a/src/Razor/test/testassets/ClassLibrary/ClassLibrary.csproj +++ b/src/Razor/test/testassets/ClassLibrary/ClassLibrary.csproj @@ -30,10 +30,10 @@ false - + - - + $(RepositoryRoot)artifacts\bin\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\$(Configuration)\netstandard2.0\ + diff --git a/src/Razor/test/testassets/ClassLibrary2/ClassLibrary2.csproj b/src/Razor/test/testassets/ClassLibrary2/ClassLibrary2.csproj index ea67bc1e7f..f07e194311 100644 --- a/src/Razor/test/testassets/ClassLibrary2/ClassLibrary2.csproj +++ b/src/Razor/test/testassets/ClassLibrary2/ClassLibrary2.csproj @@ -26,10 +26,10 @@ - + - - + $(RepositoryRoot)artifacts\bin\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\$(Configuration)\netstandard2.0\ + diff --git a/src/Razor/test/testassets/ComponentApp/ComponentApp.csproj b/src/Razor/test/testassets/ComponentApp/ComponentApp.csproj index a346743179..a5a31a82f7 100644 --- a/src/Razor/test/testassets/ComponentApp/ComponentApp.csproj +++ b/src/Razor/test/testassets/ComponentApp/ComponentApp.csproj @@ -20,12 +20,12 @@ false - - + - - + $(RepositoryRoot)artifacts\bin\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\$(Configuration)\netstandard2.0\ + + diff --git a/src/Razor/test/testassets/ComponentLibrary/ComponentLibrary.csproj b/src/Razor/test/testassets/ComponentLibrary/ComponentLibrary.csproj index c1b50b877b..e695e52b28 100644 --- a/src/Razor/test/testassets/ComponentLibrary/ComponentLibrary.csproj +++ b/src/Razor/test/testassets/ComponentLibrary/ComponentLibrary.csproj @@ -15,12 +15,12 @@ false - - + - - + $(RepositoryRoot)artifacts\bin\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\$(Configuration)\netstandard2.0\ + + diff --git a/src/Razor/test/testassets/Directory.Build.props b/src/Razor/test/testassets/Directory.Build.props index 4d6fd942d0..3f73654c48 100644 --- a/src/Razor/test/testassets/Directory.Build.props +++ b/src/Razor/test/testassets/Directory.Build.props @@ -4,6 +4,7 @@ $(MSBuildThisFileDirectory)..\..\ $([MSBuild]::EnsureTrailingSlash('$(SolutionRoot)')) + $(SolutionRoot)..\..\ $(SolutionRoot)..\..\artifacts\bin\Microsoft.NET.Sdk.Razor\ diff --git a/src/Razor/test/testassets/LargeProject/LargeProject.csproj b/src/Razor/test/testassets/LargeProject/LargeProject.csproj index c9dcbb4f7c..364466f735 100644 --- a/src/Razor/test/testassets/LargeProject/LargeProject.csproj +++ b/src/Razor/test/testassets/LargeProject/LargeProject.csproj @@ -26,10 +26,10 @@ false - + - - + $(RepositoryRoot)artifacts\bin\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\$(Configuration)\netstandard2.0\ + diff --git a/src/Razor/test/testassets/MvcWithComponents/MvcWithComponents.csproj b/src/Razor/test/testassets/MvcWithComponents/MvcWithComponents.csproj index eead930882..d225ac2239 100644 --- a/src/Razor/test/testassets/MvcWithComponents/MvcWithComponents.csproj +++ b/src/Razor/test/testassets/MvcWithComponents/MvcWithComponents.csproj @@ -23,10 +23,10 @@ false - + - - + $(RepositoryRoot)artifacts\bin\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\$(Configuration)\netstandard2.0\ + diff --git a/src/Razor/test/testassets/RestoreTestProjects/RestoreTestProjects.csproj b/src/Razor/test/testassets/RestoreTestProjects/RestoreTestProjects.csproj index 05505c5df3..60f70f66ac 100644 --- a/src/Razor/test/testassets/RestoreTestProjects/RestoreTestProjects.csproj +++ b/src/Razor/test/testassets/RestoreTestProjects/RestoreTestProjects.csproj @@ -11,12 +11,16 @@ + + + + diff --git a/src/Razor/test/testassets/SimpleMvc/SimpleMvc.csproj b/src/Razor/test/testassets/SimpleMvc/SimpleMvc.csproj index 634cf28232..13621d0e0c 100644 --- a/src/Razor/test/testassets/SimpleMvc/SimpleMvc.csproj +++ b/src/Razor/test/testassets/SimpleMvc/SimpleMvc.csproj @@ -22,10 +22,10 @@ false - + - - + $(RepositoryRoot)artifacts\bin\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\$(Configuration)\netstandard2.0\ + diff --git a/src/Razor/test/testassets/SimpleMvcFSharp/SimpleMvcFSharp.fsproj b/src/Razor/test/testassets/SimpleMvcFSharp/SimpleMvcFSharp.fsproj index eaad6c8d99..b4a810124c 100644 --- a/src/Razor/test/testassets/SimpleMvcFSharp/SimpleMvcFSharp.fsproj +++ b/src/Razor/test/testassets/SimpleMvcFSharp/SimpleMvcFSharp.fsproj @@ -26,10 +26,10 @@ - + - - + $(RepositoryRoot)artifacts\bin\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\$(Configuration)\netstandard2.0\ + diff --git a/src/Razor/test/testassets/SimplePages/SimplePages.csproj b/src/Razor/test/testassets/SimplePages/SimplePages.csproj index 634cf28232..13621d0e0c 100644 --- a/src/Razor/test/testassets/SimplePages/SimplePages.csproj +++ b/src/Razor/test/testassets/SimplePages/SimplePages.csproj @@ -22,10 +22,10 @@ false - + - - + $(RepositoryRoot)artifacts\bin\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\$(Configuration)\netstandard2.0\ +