From 2c5641829fed427c5f447316bcb61e5430fef97c Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Sat, 13 Jan 2018 15:25:21 -0800 Subject: [PATCH] Add support and tests for Razor SDK interop --- RazorViewCompilation.sln | 45 +++++++++ build/dependencies.props | 1 + ...AspNetCore.Mvc.Razor.Compatibility.targets | 95 +++++++++++++++++++ ...AspNetCore.Mvc.Razor.ViewCompilation.props | 11 +++ ...pNetCore.Mvc.Razor.ViewCompilation.targets | 14 ++- .../RazorSdkNeitherUsedTest_CoreCLR.cs | 46 +++++++++ .../RazorSdkPrecompilationUsedTest_CoreCLR.cs | 45 +++++++++ .../CoreCLRTests/RazorSdkUsedTest_CoreCLR.cs | 45 +++++++++ test/FunctionalTests/FunctionalTests.csproj | 10 ++ ...hRazorSdkPrecompilationUsed.Home.Index.txt | 8 ++ ...ApplicationWithRazorSdkUsed.Home.Index.txt | 8 ++ .../ApplicationWithRazorSdkNeitherUsed.csproj | 23 +++++ .../Controllers/HomeController.cs | 19 ++++ .../Program.cs | 26 +++++ .../Startup.cs | 21 ++++ .../Views/Home/About.cshtml | 8 ++ .../Views/Home/Index.cshtml | 6 ++ .../Views/Shared/_Layout.cshtml | 6 ++ .../Views/_ViewImports.cshtml | 2 + .../Views/_ViewStart.cshtml | 3 + ...ationWithRazorSdkPrecompilationUsed.csproj | 23 +++++ .../Controllers/HomeController.cs | 19 ++++ .../Program.cs | 26 +++++ .../Startup.cs | 21 ++++ .../Views/Home/About.cshtml | 8 ++ .../Views/Home/Index.cshtml | 6 ++ .../Views/Shared/_Layout.cshtml | 6 ++ .../Views/_ViewImports.cshtml | 2 + .../Views/_ViewStart.cshtml | 3 + .../ApplicationWithRazorSdkUsed.csproj | 25 +++++ .../Controllers/HomeController.cs | 19 ++++ .../ApplicationWithRazorSdkUsed/Program.cs | 26 +++++ .../ApplicationWithRazorSdkUsed/Startup.cs | 21 ++++ .../Views/Home/About.cshtml | 8 ++ .../Views/Home/Index.cshtml | 6 ++ .../Views/Shared/_Layout.cshtml | 6 ++ .../Views/_ViewImports.cshtml | 2 + .../Views/_ViewStart.cshtml | 3 + testapps/Directory.Build.props | 2 + 39 files changed, 673 insertions(+), 1 deletion(-) create mode 100644 src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Compatibility.targets create mode 100644 src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.props create mode 100644 test/FunctionalTests/CoreCLRTests/RazorSdkNeitherUsedTest_CoreCLR.cs create mode 100644 test/FunctionalTests/CoreCLRTests/RazorSdkPrecompilationUsedTest_CoreCLR.cs create mode 100644 test/FunctionalTests/CoreCLRTests/RazorSdkUsedTest_CoreCLR.cs create mode 100644 test/FunctionalTests/Resources/ApplicationWithRazorSdkPrecompilationUsed.Home.Index.txt create mode 100644 test/FunctionalTests/Resources/ApplicationWithRazorSdkUsed.Home.Index.txt create mode 100644 testapps/ApplicationWithRazorSdkNeitherUsed/ApplicationWithRazorSdkNeitherUsed.csproj create mode 100644 testapps/ApplicationWithRazorSdkNeitherUsed/Controllers/HomeController.cs create mode 100644 testapps/ApplicationWithRazorSdkNeitherUsed/Program.cs create mode 100644 testapps/ApplicationWithRazorSdkNeitherUsed/Startup.cs create mode 100644 testapps/ApplicationWithRazorSdkNeitherUsed/Views/Home/About.cshtml create mode 100644 testapps/ApplicationWithRazorSdkNeitherUsed/Views/Home/Index.cshtml create mode 100644 testapps/ApplicationWithRazorSdkNeitherUsed/Views/Shared/_Layout.cshtml create mode 100644 testapps/ApplicationWithRazorSdkNeitherUsed/Views/_ViewImports.cshtml create mode 100644 testapps/ApplicationWithRazorSdkNeitherUsed/Views/_ViewStart.cshtml create mode 100644 testapps/ApplicationWithRazorSdkPrecompilationUsed/ApplicationWithRazorSdkPrecompilationUsed.csproj create mode 100644 testapps/ApplicationWithRazorSdkPrecompilationUsed/Controllers/HomeController.cs create mode 100644 testapps/ApplicationWithRazorSdkPrecompilationUsed/Program.cs create mode 100644 testapps/ApplicationWithRazorSdkPrecompilationUsed/Startup.cs create mode 100644 testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/Home/About.cshtml create mode 100644 testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/Home/Index.cshtml create mode 100644 testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/Shared/_Layout.cshtml create mode 100644 testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/_ViewImports.cshtml create mode 100644 testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/_ViewStart.cshtml create mode 100644 testapps/ApplicationWithRazorSdkUsed/ApplicationWithRazorSdkUsed.csproj create mode 100644 testapps/ApplicationWithRazorSdkUsed/Controllers/HomeController.cs create mode 100644 testapps/ApplicationWithRazorSdkUsed/Program.cs create mode 100644 testapps/ApplicationWithRazorSdkUsed/Startup.cs create mode 100644 testapps/ApplicationWithRazorSdkUsed/Views/Home/About.cshtml create mode 100644 testapps/ApplicationWithRazorSdkUsed/Views/Home/Index.cshtml create mode 100644 testapps/ApplicationWithRazorSdkUsed/Views/Shared/_Layout.cshtml create mode 100644 testapps/ApplicationWithRazorSdkUsed/Views/_ViewImports.cshtml create mode 100644 testapps/ApplicationWithRazorSdkUsed/Views/_ViewStart.cshtml diff --git a/RazorViewCompilation.sln b/RazorViewCompilation.sln index a9acbea..1a67150 100644 --- a/RazorViewCompilation.sln +++ b/RazorViewCompilation.sln @@ -69,6 +69,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{75244EBD EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Tasks", "src\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Tasks\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Tasks.csproj", "{996D4DEB-1701-435E-8048-1E65790C2050}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApplicationWithRazorSdkNeitherUsed", "testapps\ApplicationWithRazorSdkNeitherUsed\ApplicationWithRazorSdkNeitherUsed.csproj", "{B64D2B9C-5737-4A39-AA46-27757F345B1E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApplicationWithRazorSdkPrecompilationUsed", "testapps\ApplicationWithRazorSdkPrecompilationUsed\ApplicationWithRazorSdkPrecompilationUsed.csproj", "{3147D272-E8E8-404D-A62C-35CD2C71FC05}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApplicationWithRazorSdkUsed", "testapps\ApplicationWithRazorSdkUsed\ApplicationWithRazorSdkUsed.csproj", "{FAA20AFB-1B2E-4A0B-A421-B83741C81644}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -283,6 +289,42 @@ Global {996D4DEB-1701-435E-8048-1E65790C2050}.Release|x64.Build.0 = Release|Any CPU {996D4DEB-1701-435E-8048-1E65790C2050}.Release|x86.ActiveCfg = Release|Any CPU {996D4DEB-1701-435E-8048-1E65790C2050}.Release|x86.Build.0 = Release|Any CPU + {B64D2B9C-5737-4A39-AA46-27757F345B1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B64D2B9C-5737-4A39-AA46-27757F345B1E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B64D2B9C-5737-4A39-AA46-27757F345B1E}.Debug|x64.ActiveCfg = Debug|Any CPU + {B64D2B9C-5737-4A39-AA46-27757F345B1E}.Debug|x64.Build.0 = Debug|Any CPU + {B64D2B9C-5737-4A39-AA46-27757F345B1E}.Debug|x86.ActiveCfg = Debug|Any CPU + {B64D2B9C-5737-4A39-AA46-27757F345B1E}.Debug|x86.Build.0 = Debug|Any CPU + {B64D2B9C-5737-4A39-AA46-27757F345B1E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B64D2B9C-5737-4A39-AA46-27757F345B1E}.Release|Any CPU.Build.0 = Release|Any CPU + {B64D2B9C-5737-4A39-AA46-27757F345B1E}.Release|x64.ActiveCfg = Release|Any CPU + {B64D2B9C-5737-4A39-AA46-27757F345B1E}.Release|x64.Build.0 = Release|Any CPU + {B64D2B9C-5737-4A39-AA46-27757F345B1E}.Release|x86.ActiveCfg = Release|Any CPU + {B64D2B9C-5737-4A39-AA46-27757F345B1E}.Release|x86.Build.0 = Release|Any CPU + {3147D272-E8E8-404D-A62C-35CD2C71FC05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3147D272-E8E8-404D-A62C-35CD2C71FC05}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3147D272-E8E8-404D-A62C-35CD2C71FC05}.Debug|x64.ActiveCfg = Debug|Any CPU + {3147D272-E8E8-404D-A62C-35CD2C71FC05}.Debug|x64.Build.0 = Debug|Any CPU + {3147D272-E8E8-404D-A62C-35CD2C71FC05}.Debug|x86.ActiveCfg = Debug|Any CPU + {3147D272-E8E8-404D-A62C-35CD2C71FC05}.Debug|x86.Build.0 = Debug|Any CPU + {3147D272-E8E8-404D-A62C-35CD2C71FC05}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3147D272-E8E8-404D-A62C-35CD2C71FC05}.Release|Any CPU.Build.0 = Release|Any CPU + {3147D272-E8E8-404D-A62C-35CD2C71FC05}.Release|x64.ActiveCfg = Release|Any CPU + {3147D272-E8E8-404D-A62C-35CD2C71FC05}.Release|x64.Build.0 = Release|Any CPU + {3147D272-E8E8-404D-A62C-35CD2C71FC05}.Release|x86.ActiveCfg = Release|Any CPU + {3147D272-E8E8-404D-A62C-35CD2C71FC05}.Release|x86.Build.0 = Release|Any CPU + {FAA20AFB-1B2E-4A0B-A421-B83741C81644}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FAA20AFB-1B2E-4A0B-A421-B83741C81644}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FAA20AFB-1B2E-4A0B-A421-B83741C81644}.Debug|x64.ActiveCfg = Debug|Any CPU + {FAA20AFB-1B2E-4A0B-A421-B83741C81644}.Debug|x64.Build.0 = Debug|Any CPU + {FAA20AFB-1B2E-4A0B-A421-B83741C81644}.Debug|x86.ActiveCfg = Debug|Any CPU + {FAA20AFB-1B2E-4A0B-A421-B83741C81644}.Debug|x86.Build.0 = Debug|Any CPU + {FAA20AFB-1B2E-4A0B-A421-B83741C81644}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FAA20AFB-1B2E-4A0B-A421-B83741C81644}.Release|Any CPU.Build.0 = Release|Any CPU + {FAA20AFB-1B2E-4A0B-A421-B83741C81644}.Release|x64.ActiveCfg = Release|Any CPU + {FAA20AFB-1B2E-4A0B-A421-B83741C81644}.Release|x64.Build.0 = Release|Any CPU + {FAA20AFB-1B2E-4A0B-A421-B83741C81644}.Release|x86.ActiveCfg = Release|Any CPU + {FAA20AFB-1B2E-4A0B-A421-B83741C81644}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -305,6 +347,9 @@ Global {08552602-37E7-48A7-95A2-BB1A1F57C804} = {0DC7C88C-E3DB-46DF-B47E-AC5ECB2A16B7} {779BACC4-B20E-4F73-A9C7-350443CF1941} = {0DC7C88C-E3DB-46DF-B47E-AC5ECB2A16B7} {996D4DEB-1701-435E-8048-1E65790C2050} = {02F7AA35-91AF-491E-9F0E-03CFAF86C720} + {B64D2B9C-5737-4A39-AA46-27757F345B1E} = {0DC7C88C-E3DB-46DF-B47E-AC5ECB2A16B7} + {3147D272-E8E8-404D-A62C-35CD2C71FC05} = {0DC7C88C-E3DB-46DF-B47E-AC5ECB2A16B7} + {FAA20AFB-1B2E-4A0B-A421-B83741C81644} = {0DC7C88C-E3DB-46DF-B47E-AC5ECB2A16B7} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {177268A1-F5B2-451E-8ABE-BEF0C572481A} diff --git a/build/dependencies.props b/build/dependencies.props index 0ba9617..7779c97 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -8,6 +8,7 @@ 2.1.0-preview1-28072 2.1.0-preview1-28072 2.1.0-preview1-28072 + 2.1.0-preview1-28072 2.1.0-preview1-28072 0.5.0-preview1-28072 2.1.0-preview1-28072 diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Compatibility.targets b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Compatibility.targets new file mode 100644 index 0000000..18017d5 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Compatibility.targets @@ -0,0 +1,95 @@ + + + + <_MvcPrecompilationExplicitlyEnabled Condition="'$(MvcRazorCompileOnPublish)'=='true'">true + <_MvcPrecompilationExplicitlyDisabled Condition="'$(MvcRazorCompileOnPublish)'=='false'">true + <_RazorSdkExplicitlyEnabled Condition="'$(RazorCompileOnBuild)'=='true' or '$(RazorCompileOnPublish)'=='true'">true + <_RazorSdkExplicitlyDisabled Condition="'$(RazorCompileOnBuild)'=='false' and '$(RazorCompileOnPublish)'=='false'">true + + + + + <_RazorSdkCompatibilityError Include="Using the Razor SDK (RazorCompileOnBuild or RazorCompileOnPublish) and MvcPrecompilation (MvcRazorCompileOnPublish) together is not supported'."/> + + + + + false + false + + + + + false + false + + + + + <_MvcPrecompilationImplicitlyEnabled>true + + + + + false + false + + + + + <_RazorSdkCompatibilityError Include="Using the Razor SDK (RazorCompileOnBuild or RazorCompileOnPublish) and MvcRazorFilesToCompile together is not supported. To disable the Razor SDK targets, and use MvcPrecompilation set the property 'MvcRazorCompileOnPublish' to 'true' in the project file. To use the Razor SDK instead, replace 'MvcRazorFilesToCompile' with 'RazorGenerate'"/> + + + + diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.props b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.props new file mode 100644 index 0000000..a777086 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.props @@ -0,0 +1,11 @@ + + + + + $(MSBuildThisFileDirectory)Microsoft.AspNetCore.Mvc.Razor.Compatibility.targets + + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets index dfe3bf8..7744c4d 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets +++ b/src/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets @@ -1,5 +1,15 @@ - + + + + + + + + $(IntermediateOutputPath) <_MvcRazorOutputFullPath Condition="'$(_MvcRazorOutputFullPath)'==''">$([MSBuild]::EnsureTrailingSlash('$(MvcRazorOutputPath)'))$(AssemblyName).PrecompiledViews.dll @@ -13,6 +23,7 @@ + diff --git a/test/FunctionalTests/CoreCLRTests/RazorSdkNeitherUsedTest_CoreCLR.cs b/test/FunctionalTests/CoreCLRTests/RazorSdkNeitherUsedTest_CoreCLR.cs new file mode 100644 index 0000000..faea04a --- /dev/null +++ b/test/FunctionalTests/CoreCLRTests/RazorSdkNeitherUsedTest_CoreCLR.cs @@ -0,0 +1,46 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Server.IntegrationTesting; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + // Tests that cover cases where both Razor SDK and MvcPrecompilation are installed. This is the default in 2.1 + public class RazorSdkNeitherUsedTest_CoreCLR : LoggedTest, IClassFixture> + { + public RazorSdkNeitherUsedTest_CoreCLR( + CoreCLRApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [Fact] + public async Task Publish_HasNoPrecompilation() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await RetryHelper.RetryRequest( + () => deployment.HttpClient.GetAsync(deployment.ApplicationBaseUri), + loggerFactory.CreateLogger(Fixture.ApplicationName), + retryCount: 5); + + // Assert + Assert.False(File.Exists(Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkNeitherUsed.PrecompiledViews.dll"))); + Assert.False(File.Exists(Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkNeitherUsed.Views.dll"))); + } + } + } +} diff --git a/test/FunctionalTests/CoreCLRTests/RazorSdkPrecompilationUsedTest_CoreCLR.cs b/test/FunctionalTests/CoreCLRTests/RazorSdkPrecompilationUsedTest_CoreCLR.cs new file mode 100644 index 0000000..130553d --- /dev/null +++ b/test/FunctionalTests/CoreCLRTests/RazorSdkPrecompilationUsedTest_CoreCLR.cs @@ -0,0 +1,45 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.IO; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + // Tests that cover cases where both Razor SDK and MvcPrecompilation are installed. This is the default in 2.1 + public class RazorSdkPrecompilationUsedTest_CoreCLR : LoggedTest, IClassFixture> + { + public RazorSdkPrecompilationUsedTest_CoreCLR( + CoreCLRApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [Fact] + public async Task Publish_UsesRazorSDK() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + deployment.ApplicationBaseUri, + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + Assert.True(File.Exists(Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkPrecompilationUsed.PrecompiledViews.dll"))); + Assert.False(File.Exists(Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkPrecompilationUsed.Views.dll"))); + TestEmbeddedResource.AssertContent("ApplicationWithRazorSdkPrecompilationUsed.Home.Index.txt", response); + } + } + } +} diff --git a/test/FunctionalTests/CoreCLRTests/RazorSdkUsedTest_CoreCLR.cs b/test/FunctionalTests/CoreCLRTests/RazorSdkUsedTest_CoreCLR.cs new file mode 100644 index 0000000..4c23395 --- /dev/null +++ b/test/FunctionalTests/CoreCLRTests/RazorSdkUsedTest_CoreCLR.cs @@ -0,0 +1,45 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.IO; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging.Testing; +using Xunit; +using Xunit.Abstractions; + +namespace FunctionalTests +{ + // Tests that cover cases where both Razor SDK and MvcPrecompilation are installed. This is the default in 2.1 + public class RazorSdkUsedTest_CoreCLR : LoggedTest, IClassFixture> + { + public RazorSdkUsedTest_CoreCLR( + CoreCLRApplicationTestFixture fixture, + ITestOutputHelper output) + : base(output) + { + Fixture = fixture; + } + + public ApplicationTestFixture Fixture { get; } + + [Fact] + public async Task Publish_UsesRazorSDK() + { + using (StartLog(out var loggerFactory)) + { + // Arrange + var deployment = await Fixture.CreateDeploymentAsync(loggerFactory); + + // Act + var response = await deployment.HttpClient.GetStringWithRetryAsync( + deployment.ApplicationBaseUri, + loggerFactory.CreateLogger(Fixture.ApplicationName)); + + // Assert + Assert.False(File.Exists(Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkUsed.PrecompiledViews.dll"))); + Assert.True(File.Exists(Path.Combine(deployment.ContentRoot, "ApplicationWithRazorSdkUsed.Views.dll"))); + TestEmbeddedResource.AssertContent("ApplicationWithRazorSdkUsed.Home.Index.txt", response); + } + } + } +} diff --git a/test/FunctionalTests/FunctionalTests.csproj b/test/FunctionalTests/FunctionalTests.csproj index 2ea5cec..b904ade 100644 --- a/test/FunctionalTests/FunctionalTests.csproj +++ b/test/FunctionalTests/FunctionalTests.csproj @@ -18,6 +18,13 @@ + + + + + + + @@ -32,6 +39,9 @@ + + + diff --git a/test/FunctionalTests/Resources/ApplicationWithRazorSdkPrecompilationUsed.Home.Index.txt b/test/FunctionalTests/Resources/ApplicationWithRazorSdkPrecompilationUsed.Home.Index.txt new file mode 100644 index 0000000..ed399bf --- /dev/null +++ b/test/FunctionalTests/Resources/ApplicationWithRazorSdkPrecompilationUsed.Home.Index.txt @@ -0,0 +1,8 @@ + + + + +ApplicationWithRazorSdkPrecompilationUsed.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null +Hello from Index! + + \ No newline at end of file diff --git a/test/FunctionalTests/Resources/ApplicationWithRazorSdkUsed.Home.Index.txt b/test/FunctionalTests/Resources/ApplicationWithRazorSdkUsed.Home.Index.txt new file mode 100644 index 0000000..0ee1cc0 --- /dev/null +++ b/test/FunctionalTests/Resources/ApplicationWithRazorSdkUsed.Home.Index.txt @@ -0,0 +1,8 @@ + + + + +ApplicationWithRazorSdkUsed.Views, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null +Hello from Index! + + \ No newline at end of file diff --git a/testapps/ApplicationWithRazorSdkNeitherUsed/ApplicationWithRazorSdkNeitherUsed.csproj b/testapps/ApplicationWithRazorSdkNeitherUsed/ApplicationWithRazorSdkNeitherUsed.csproj new file mode 100644 index 0000000..fbe8aa5 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkNeitherUsed/ApplicationWithRazorSdkNeitherUsed.csproj @@ -0,0 +1,23 @@ + + + + $(StandardTestAppTfms) + + + false + + + ApplicationWithRazorSdkNeitherUsed.Views + + + + + + + + + + + diff --git a/testapps/ApplicationWithRazorSdkNeitherUsed/Controllers/HomeController.cs b/testapps/ApplicationWithRazorSdkNeitherUsed/Controllers/HomeController.cs new file mode 100644 index 0000000..e2d7c9f --- /dev/null +++ b/testapps/ApplicationWithRazorSdkNeitherUsed/Controllers/HomeController.cs @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.Mvc; + +namespace ApplicationWithRazorSdkNeitherUsed.Controllers +{ + public class HomeController : Controller + { + public IActionResult Index() + { + return View("Views/Home/Index.cshtml"); + } + + public IActionResult About() + { + ViewData["Message"] = "Your application description page."; + + return View(); + } + } +} diff --git a/testapps/ApplicationWithRazorSdkNeitherUsed/Program.cs b/testapps/ApplicationWithRazorSdkNeitherUsed/Program.cs new file mode 100644 index 0000000..faefdc6 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkNeitherUsed/Program.cs @@ -0,0 +1,26 @@ +using System.IO; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; + +namespace ApplicationWithRazorSdkNeitherUsed +{ + public class Program + { + public static void Main(string[] args) + { + var config = new ConfigurationBuilder() + .AddCommandLine(args) + .AddEnvironmentVariables(prefix: "ASPNETCORE_") + .Build(); + + var host = new WebHostBuilder() + .UseConfiguration(config) + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/testapps/ApplicationWithRazorSdkNeitherUsed/Startup.cs b/testapps/ApplicationWithRazorSdkNeitherUsed/Startup.cs new file mode 100644 index 0000000..4b06309 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkNeitherUsed/Startup.cs @@ -0,0 +1,21 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace ApplicationWithRazorSdkNeitherUsed +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + // Add framework services. + services.AddMvc(); + } + + public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) + { + loggerFactory.AddConsole(); + app.UseMvcWithDefaultRoute(); + } + } +} diff --git a/testapps/ApplicationWithRazorSdkNeitherUsed/Views/Home/About.cshtml b/testapps/ApplicationWithRazorSdkNeitherUsed/Views/Home/About.cshtml new file mode 100644 index 0000000..bbc0672 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkNeitherUsed/Views/Home/About.cshtml @@ -0,0 +1,8 @@ +@{ + Layout = "../Shared/_Layout.cshtml"; + ViewData["Title"] = "About"; +} +

@ViewData["Title"].

+

@ViewData["Message"]

+ +

Use this area to provide additional information.

diff --git a/testapps/ApplicationWithRazorSdkNeitherUsed/Views/Home/Index.cshtml b/testapps/ApplicationWithRazorSdkNeitherUsed/Views/Home/Index.cshtml new file mode 100644 index 0000000..d29ab9c --- /dev/null +++ b/testapps/ApplicationWithRazorSdkNeitherUsed/Views/Home/Index.cshtml @@ -0,0 +1,6 @@ +@{ + ViewData["Title"] = "Home Page"; +} + +@GetType().AssemblyQualifiedName +Hello from Index! \ No newline at end of file diff --git a/testapps/ApplicationWithRazorSdkNeitherUsed/Views/Shared/_Layout.cshtml b/testapps/ApplicationWithRazorSdkNeitherUsed/Views/Shared/_Layout.cshtml new file mode 100644 index 0000000..4c90941 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkNeitherUsed/Views/Shared/_Layout.cshtml @@ -0,0 +1,6 @@ + + + + @RenderBody() + + \ No newline at end of file diff --git a/testapps/ApplicationWithRazorSdkNeitherUsed/Views/_ViewImports.cshtml b/testapps/ApplicationWithRazorSdkNeitherUsed/Views/_ViewImports.cshtml new file mode 100644 index 0000000..d320fb1 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkNeitherUsed/Views/_ViewImports.cshtml @@ -0,0 +1,2 @@ +@using ApplicationWithRazorSdkNeitherUsed +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/testapps/ApplicationWithRazorSdkNeitherUsed/Views/_ViewStart.cshtml b/testapps/ApplicationWithRazorSdkNeitherUsed/Views/_ViewStart.cshtml new file mode 100644 index 0000000..1b4f3a0 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkNeitherUsed/Views/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "Shared/_Layout.cshtml"; +} diff --git a/testapps/ApplicationWithRazorSdkPrecompilationUsed/ApplicationWithRazorSdkPrecompilationUsed.csproj b/testapps/ApplicationWithRazorSdkPrecompilationUsed/ApplicationWithRazorSdkPrecompilationUsed.csproj new file mode 100644 index 0000000..322c04a --- /dev/null +++ b/testapps/ApplicationWithRazorSdkPrecompilationUsed/ApplicationWithRazorSdkPrecompilationUsed.csproj @@ -0,0 +1,23 @@ + + + + $(StandardTestAppTfms) + + + true + + + ApplicationWithRazorSdkPrecompilationUsed.Views + + + + + + + + + + + diff --git a/testapps/ApplicationWithRazorSdkPrecompilationUsed/Controllers/HomeController.cs b/testapps/ApplicationWithRazorSdkPrecompilationUsed/Controllers/HomeController.cs new file mode 100644 index 0000000..3a08839 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkPrecompilationUsed/Controllers/HomeController.cs @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.Mvc; + +namespace ApplicationWithRazorSdkPrecompilationUsed.Controllers +{ + public class HomeController : Controller + { + public IActionResult Index() + { + return View("Views/Home/Index.cshtml"); + } + + public IActionResult About() + { + ViewData["Message"] = "Your application description page."; + + return View(); + } + } +} diff --git a/testapps/ApplicationWithRazorSdkPrecompilationUsed/Program.cs b/testapps/ApplicationWithRazorSdkPrecompilationUsed/Program.cs new file mode 100644 index 0000000..96af521 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkPrecompilationUsed/Program.cs @@ -0,0 +1,26 @@ +using System.IO; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; + +namespace ApplicationWithRazorSdkPrecompilationUsed +{ + public class Program + { + public static void Main(string[] args) + { + var config = new ConfigurationBuilder() + .AddCommandLine(args) + .AddEnvironmentVariables(prefix: "ASPNETCORE_") + .Build(); + + var host = new WebHostBuilder() + .UseConfiguration(config) + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/testapps/ApplicationWithRazorSdkPrecompilationUsed/Startup.cs b/testapps/ApplicationWithRazorSdkPrecompilationUsed/Startup.cs new file mode 100644 index 0000000..16c835e --- /dev/null +++ b/testapps/ApplicationWithRazorSdkPrecompilationUsed/Startup.cs @@ -0,0 +1,21 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace ApplicationWithRazorSdkPrecompilationUsed +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + // Add framework services. + services.AddMvc(); + } + + public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) + { + loggerFactory.AddConsole(); + app.UseMvcWithDefaultRoute(); + } + } +} diff --git a/testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/Home/About.cshtml b/testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/Home/About.cshtml new file mode 100644 index 0000000..bbc0672 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/Home/About.cshtml @@ -0,0 +1,8 @@ +@{ + Layout = "../Shared/_Layout.cshtml"; + ViewData["Title"] = "About"; +} +

@ViewData["Title"].

+

@ViewData["Message"]

+ +

Use this area to provide additional information.

diff --git a/testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/Home/Index.cshtml b/testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/Home/Index.cshtml new file mode 100644 index 0000000..b2bf7cf --- /dev/null +++ b/testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/Home/Index.cshtml @@ -0,0 +1,6 @@ +@{ + ViewData["Title"] = "Home Page"; +} + +@GetType().Assembly.FullName +Hello from Index! \ No newline at end of file diff --git a/testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/Shared/_Layout.cshtml b/testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/Shared/_Layout.cshtml new file mode 100644 index 0000000..4c90941 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/Shared/_Layout.cshtml @@ -0,0 +1,6 @@ + + + + @RenderBody() + + \ No newline at end of file diff --git a/testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/_ViewImports.cshtml b/testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/_ViewImports.cshtml new file mode 100644 index 0000000..cde83e7 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/_ViewImports.cshtml @@ -0,0 +1,2 @@ +@using ApplicationWithRazorSdkPrecompilationUsed +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/_ViewStart.cshtml b/testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/_ViewStart.cshtml new file mode 100644 index 0000000..1b4f3a0 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkPrecompilationUsed/Views/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "Shared/_Layout.cshtml"; +} diff --git a/testapps/ApplicationWithRazorSdkUsed/ApplicationWithRazorSdkUsed.csproj b/testapps/ApplicationWithRazorSdkUsed/ApplicationWithRazorSdkUsed.csproj new file mode 100644 index 0000000..d97fb72 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkUsed/ApplicationWithRazorSdkUsed.csproj @@ -0,0 +1,25 @@ + + + + + + + + $(StandardTestAppTfms) + + + true + + + ApplicationWithRazorSdkUsed.Views + + + + + + + + + + + diff --git a/testapps/ApplicationWithRazorSdkUsed/Controllers/HomeController.cs b/testapps/ApplicationWithRazorSdkUsed/Controllers/HomeController.cs new file mode 100644 index 0000000..71fe569 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkUsed/Controllers/HomeController.cs @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.Mvc; + +namespace ApplicationWithRazorSdkUsed.Controllers +{ + public class HomeController : Controller + { + public IActionResult Index() + { + return View("Views/Home/Index.cshtml"); + } + + public IActionResult About() + { + ViewData["Message"] = "Your application description page."; + + return View(); + } + } +} diff --git a/testapps/ApplicationWithRazorSdkUsed/Program.cs b/testapps/ApplicationWithRazorSdkUsed/Program.cs new file mode 100644 index 0000000..c0db031 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkUsed/Program.cs @@ -0,0 +1,26 @@ +using System.IO; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; + +namespace ApplicationWithRazorSdkUsed +{ + public class Program + { + public static void Main(string[] args) + { + var config = new ConfigurationBuilder() + .AddCommandLine(args) + .AddEnvironmentVariables(prefix: "ASPNETCORE_") + .Build(); + + var host = new WebHostBuilder() + .UseConfiguration(config) + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/testapps/ApplicationWithRazorSdkUsed/Startup.cs b/testapps/ApplicationWithRazorSdkUsed/Startup.cs new file mode 100644 index 0000000..8c6e88e --- /dev/null +++ b/testapps/ApplicationWithRazorSdkUsed/Startup.cs @@ -0,0 +1,21 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace ApplicationWithRazorSdkUsed +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + // Add framework services. + services.AddMvc(); + } + + public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) + { + loggerFactory.AddConsole(); + app.UseMvcWithDefaultRoute(); + } + } +} diff --git a/testapps/ApplicationWithRazorSdkUsed/Views/Home/About.cshtml b/testapps/ApplicationWithRazorSdkUsed/Views/Home/About.cshtml new file mode 100644 index 0000000..bbc0672 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkUsed/Views/Home/About.cshtml @@ -0,0 +1,8 @@ +@{ + Layout = "../Shared/_Layout.cshtml"; + ViewData["Title"] = "About"; +} +

@ViewData["Title"].

+

@ViewData["Message"]

+ +

Use this area to provide additional information.

diff --git a/testapps/ApplicationWithRazorSdkUsed/Views/Home/Index.cshtml b/testapps/ApplicationWithRazorSdkUsed/Views/Home/Index.cshtml new file mode 100644 index 0000000..b2bf7cf --- /dev/null +++ b/testapps/ApplicationWithRazorSdkUsed/Views/Home/Index.cshtml @@ -0,0 +1,6 @@ +@{ + ViewData["Title"] = "Home Page"; +} + +@GetType().Assembly.FullName +Hello from Index! \ No newline at end of file diff --git a/testapps/ApplicationWithRazorSdkUsed/Views/Shared/_Layout.cshtml b/testapps/ApplicationWithRazorSdkUsed/Views/Shared/_Layout.cshtml new file mode 100644 index 0000000..4c90941 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkUsed/Views/Shared/_Layout.cshtml @@ -0,0 +1,6 @@ + + + + @RenderBody() + + \ No newline at end of file diff --git a/testapps/ApplicationWithRazorSdkUsed/Views/_ViewImports.cshtml b/testapps/ApplicationWithRazorSdkUsed/Views/_ViewImports.cshtml new file mode 100644 index 0000000..c384203 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkUsed/Views/_ViewImports.cshtml @@ -0,0 +1,2 @@ +@using ApplicationWithRazorSdkUsed +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/testapps/ApplicationWithRazorSdkUsed/Views/_ViewStart.cshtml b/testapps/ApplicationWithRazorSdkUsed/Views/_ViewStart.cshtml new file mode 100644 index 0000000..1b4f3a0 --- /dev/null +++ b/testapps/ApplicationWithRazorSdkUsed/Views/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "Shared/_Layout.cshtml"; +} diff --git a/testapps/Directory.Build.props b/testapps/Directory.Build.props index 35e9c46..70cec33 100644 --- a/testapps/Directory.Build.props +++ b/testapps/Directory.Build.props @@ -15,4 +15,6 @@ false
+ +