diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ProjectDirectory.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ProjectDirectory.cs index 4a37b0e624..c9d2ab4a14 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ProjectDirectory.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/ProjectDirectory.cs @@ -42,17 +42,17 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests foreach (var project in new string[] { projectName, }.Concat(additionalProjects)) { - var projectRoot = Path.Combine(solutionRoot, "test", "testapps", project); + var testAppsRoot = Path.Combine(solutionRoot, "test", "testapps"); + var projectRoot = Path.Combine(testAppsRoot, project); if (!Directory.Exists(projectRoot)) { throw new InvalidOperationException($"Could not find project at '{projectRoot}'"); } var projectDestination = Path.Combine(destinationPath, project); - Directory.CreateDirectory(projectDestination); - CopyDirectory(new DirectoryInfo(projectRoot), new DirectoryInfo(projectDestination)); - CreateDirectoryProps(projectRoot, binariesRoot, destinationPath); - CreateDirectoryTargets(destinationPath); + var projectDestinationDir = Directory.CreateDirectory(projectDestination); + CopyDirectory(new DirectoryInfo(projectRoot), projectDestinationDir); + SetupDirectoryBuildFiles(solutionRoot, binariesRoot, testAppsRoot, projectDestination); } CopyGlobalJson(solutionRoot, destinationPath); @@ -86,38 +86,24 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests } } - void CreateDirectoryProps(string originalProjectRoot, string binariesRoot, string projectRoot) + void SetupDirectoryBuildFiles(string solutionRoot, string binariesRoot, string testAppsRoot, string projectDestination) { -#if DEBUG - var configuration = "Debug"; -#elif RELEASE - var configuration = "Release"; -#else -#error Unknown Configuration -#endif - - var text = $@" - - + var beforeDirectoryPropsContent = +$@" - {originalProjectRoot} + {solutionRoot} {binariesRoot} - <_RazorMSBuildRoot>$(OriginalProjectRoot)\..\..\..\src\Microsoft.AspNetCore.Razor.Design\bin\{configuration}\netstandard2.0\ - - -"; - File.WriteAllText(Path.Combine(projectRoot, "Directory.Build.props"), text); - } +"; + File.WriteAllText(Path.Combine(projectDestination, "Before.Directory.Build.props"), beforeDirectoryPropsContent); - void CreateDirectoryTargets(string projectRoot) - { - var text = $@" - - - -"; - File.WriteAllText(Path.Combine(projectRoot, "Directory.Build.targets"), text); + new List { "Directory.Build.props", "Directory.Build.targets" } + .ForEach(file => + { + var source = Path.Combine(testAppsRoot, file); + var destination = Path.Combine(projectDestination, file); + File.Copy(source, destination); + }); } void CopyGlobalJson(string solutionRoot, string projectRoot) diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs index af4dd592d1..c00b317007 100644 --- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorGenerateIntegrationTest.cs @@ -207,13 +207,12 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { var content = @" - "; - File.WriteAllText(Path.Combine(Project.DirectoryPath, "Directory.Build.props"), content); + File.WriteAllText(Path.Combine(Project.DirectoryPath, "After.Directory.Build.props"), content); var result = await DotnetMSBuild(RazorGenerateTarget); @@ -229,7 +228,6 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests { var content = @" - false @@ -238,7 +236,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests "; - File.WriteAllText(Path.Combine(Project.DirectoryPath, "Directory.Build.props"), content); + File.WriteAllText(Path.Combine(Project.DirectoryPath, "After.Directory.Build.props"), content); var result = await DotnetMSBuild(RazorGenerateTarget); diff --git a/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj b/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj index 2ef0434947..a1090fca82 100644 --- a/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj +++ b/test/testapps/AppWithP2PReference/AppWithP2PReference.csproj @@ -1,4 +1,11 @@ + + <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ + + + + + netcoreapp2.0 @@ -9,17 +16,4 @@ - - - - - - - - - - - - - diff --git a/test/testapps/ClassLibrary/ClassLibrary.csproj b/test/testapps/ClassLibrary/ClassLibrary.csproj index 7e9ea198c6..21588daae9 100644 --- a/test/testapps/ClassLibrary/ClassLibrary.csproj +++ b/test/testapps/ClassLibrary/ClassLibrary.csproj @@ -1,4 +1,11 @@ + + <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ + + + + + netcoreapp2.0 @@ -6,22 +13,9 @@ RazorSDK - - - - - - false - - - - - - - diff --git a/test/testapps/Directory.Build.props b/test/testapps/Directory.Build.props new file mode 100644 index 0000000000..475a18a63f --- /dev/null +++ b/test/testapps/Directory.Build.props @@ -0,0 +1,25 @@ + + + + + $(MSBuildThisFileDirectory)..\..\ + $([MSBuild]::EnsureTrailingSlash('$(SolutionRoot)')) + + + + + + + + + + + + + + + + + + + diff --git a/test/testapps/Directory.Build.targets b/test/testapps/Directory.Build.targets new file mode 100644 index 0000000000..73a13b4997 --- /dev/null +++ b/test/testapps/Directory.Build.targets @@ -0,0 +1,3 @@ + + + diff --git a/test/testapps/SimpleMvc/SimpleMvc.csproj b/test/testapps/SimpleMvc/SimpleMvc.csproj index e553d82b2a..caddabdab8 100644 --- a/test/testapps/SimpleMvc/SimpleMvc.csproj +++ b/test/testapps/SimpleMvc/SimpleMvc.csproj @@ -1,21 +1,15 @@ + + <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ + + + + + netcoreapp2.0 RazorSDK - - - - - - - - - - - - - diff --git a/test/testapps/SimplePages/SimplePages.csproj b/test/testapps/SimplePages/SimplePages.csproj index e553d82b2a..caddabdab8 100644 --- a/test/testapps/SimplePages/SimplePages.csproj +++ b/test/testapps/SimplePages/SimplePages.csproj @@ -1,21 +1,15 @@ + + <_RazorMSBuildRoot>$(SolutionRoot)src\Microsoft.AspNetCore.Razor.Design\bin\$(Configuration)\netstandard2.0\ + + + + + netcoreapp2.0 RazorSDK - - - - - - - - - - - - -