Add support and tests for Razor SDK interop

This commit is contained in:
Ryan Nowak 2018-01-13 15:25:21 -08:00
Родитель fd481baab8
Коммит 2c5641829f
39 изменённых файлов: 673 добавлений и 1 удалений

Просмотреть файл

@ -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}

Просмотреть файл

@ -8,6 +8,7 @@
<MicrosoftAspNetCoreHostingPackageVersion>2.1.0-preview1-28072</MicrosoftAspNetCoreHostingPackageVersion>
<MicrosoftAspNetCoreMvcPackageVersion>2.1.0-preview1-28072</MicrosoftAspNetCoreMvcPackageVersion>
<MicrosoftAspNetCoreMvcRazorPagesPackageVersion>2.1.0-preview1-28072</MicrosoftAspNetCoreMvcRazorPagesPackageVersion>
<MicrosoftAspNetCoreRazorDesignPackageVersion>2.1.0-preview1-28072</MicrosoftAspNetCoreRazorDesignPackageVersion>
<MicrosoftAspNetCoreRazorRuntimePackageVersion>2.1.0-preview1-28072</MicrosoftAspNetCoreRazorRuntimePackageVersion>
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.5.0-preview1-28072</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.1.0-preview1-28072</MicrosoftAspNetCoreServerKestrelPackageVersion>

Просмотреть файл

@ -0,0 +1,95 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
Either precompilation or Razor SDK should be allowed to run, but not both. We make the decision here about which one
wins based on whether the project file has set any properties/items that we care about.
We expect these targets to always be imported before the Razor SDK targets so we can make the decision in the least
breaking way.
There are a few important cases.
1. The project doesn't customize anything. We expect that this is the most common case, and would be the default
for applications created in 2.0. The desired outcome is that compilation happens on publish using Razor SDK.
We can accomplish this without any special handling in this file, it's the default.
2. The application has explicitly enabled both MvcPrecompilation and Razor SDK. This should result in an error.
3. The project explicitly turned on MvcPrecompilation. The desired outcome is that compilation happens
on publish using MvcPrecompilation.
4. The project explicitly turned off MvcPrecompilation. This happens because MvcPrecompilation wasn't a great fit
for all scenarios. The desired outcome is that neither Razor SDK nor MvcPrecompilation runs.
5. The project customized some settings from MvcPrecompilation. There are a few of cases here, and the challenge
is dealing with evaluation order (both items and properties). The desired outcome is that compilation happens
on publish using MvcPrecompilation.
5a. If the application just used the properties, we can turn off Razor SDK during evaluation.
5b. If the application adds files to MvcRazorFilesToCompile we can't detect this early enough to disable the
the Razor SDK due to evaluation (items vs properties). We have to report an error in this case.
5c. If the application explicitly enables Razor SDK, this should result in an error.
There's no supported case where we used both systems, and there's no case where we need to provide a warning about
compatibility or migration.
-->
<PropertyGroup>
<_MvcPrecompilationExplicitlyEnabled Condition="'$(MvcRazorCompileOnPublish)'=='true'">true</_MvcPrecompilationExplicitlyEnabled>
<_MvcPrecompilationExplicitlyDisabled Condition="'$(MvcRazorCompileOnPublish)'=='false'">true</_MvcPrecompilationExplicitlyDisabled>
<_RazorSdkExplicitlyEnabled Condition="'$(RazorCompileOnBuild)'=='true' or '$(RazorCompileOnPublish)'=='true'">true</_RazorSdkExplicitlyEnabled>
<_RazorSdkExplicitlyDisabled Condition="'$(RazorCompileOnBuild)'=='false' and '$(RazorCompileOnPublish)'=='false'">true</_RazorSdkExplicitlyDisabled>
</PropertyGroup>
<ItemGroup Condition="'$(_MvcPrecompilationExplicitlyEnabled)'=='true' and '$(_RazorSdkExplicitlyEnabled)'=='true'">
<!--
This is case 2, both sets of targets are explicitly enabled. Report an error because we don't support what the
project is asking for.
-->
<_RazorSdkCompatibilityError Include="Using the Razor SDK (RazorCompileOnBuild or RazorCompileOnPublish) and MvcPrecompilation (MvcRazorCompileOnPublish) together is not supported'."/>
</ItemGroup>
<PropertyGroup Condition="'$(_MvcPrecompilationExplicitlyEnabled)'=='true' and '$(_RazorSdkExplicitlyEnabled)'!='true'">
<!--
This is case 3, we should use MvcPrecompilation and ignore the Razor SDK.
-->
<RazorCompileOnPublish>false</RazorCompileOnPublish>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(_MvcPrecompilationExplicitlyDisabled)'=='true' and '$(_RazorSdkExplicitlyEnabled)'!='true'">
<!--
This is case 4, we should ignore the Razor SDK to be as compatible as possible with the 2.0 expectations.
-->
<RazorCompileOnPublish>false</RazorCompileOnPublish>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(_MvcPrecompilationExplicitlyEnabled)'!='true' and ('$(MvcRazorOutputPath)'!='' or '$(MvcRazorContentRoot)'!='' or '$(MvcRazorExcludeViewFilesFromPublish)'!='' or '$(MvcRazorExcludeRefAssembliesFromPublish)'!='')">
<!--
If we get here we know that the project file has set some of the MvcPrecompilation properties (case 5).
Unfortunately we can't detect if the project has added anything to MvcRazorFilesToCompile at this point, so we can't
skip the Razor SDK targets.
-->
<_MvcPrecompilationImplicitlyEnabled>true</_MvcPrecompilationImplicitlyEnabled>
</PropertyGroup>
<PropertyGroup Condition="'$(_MvcPrecompilationImplicitlyEnabled)'=='true' and '$(_RazorSdkExplicitlyEnabled)'!='true'">
<!--
This is case 5a, the project file sets MvcPrecompilation setttings, and we can safely turn off the Razor SDK.
-->
<RazorCompileOnPublish>false</RazorCompileOnPublish>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
</PropertyGroup>
<ItemGroup Condition="'@(MvcRazorFilesToCompile)'!='' and '$(_MvcPrecompilationExplicitlyDisabled)'!='true' and '$(_RazorSdkExplicitlyDisabled)'!='true'">
<!--
This is case 5b or 5b, the project file has modified the MvcPrecompilation items but hasn't turned the Razor SDK.
We can't disable the Razor SDK at this point, it's too late in the evaluation pass.
-->
<_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'"/>
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,11 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!--
Force the precompilation compatibility targets to be imported before the Razor targets. We only want one of precompilation or Razor SDK
to run. We use the precompilation targets to determine which one wins.
-->
<CustomBeforeRazorSdkTargets>$(MSBuildThisFileDirectory)Microsoft.AspNetCore.Mvc.Razor.Compatibility.targets</CustomBeforeRazorSdkTargets>
</PropertyGroup>
</Project>

Просмотреть файл

@ -1,5 +1,15 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="_ResolveInputArguments">
<!--
Reports compatibility errors between these targets and the Razor SDK that were discovered during
the evaluation phase.
-->
<Target Name="_ReportRazorSdkCompatibilityError" Condition="'@(_RazorSdkCompatibilityError)'!=''" BeforeTargets="RazorResolveGenerateInputs">
<Error Text="@(_RazorSdkCompatibilityError)"/>
</Target>
<Target Name="_ResolveInputArguments" DependsOnTargets="_ReportRazorSdkCompatibilityError">
<PropertyGroup>
<MvcRazorOutputPath Condition="'$(MvcRazorOutputPath)'==''">$(IntermediateOutputPath)</MvcRazorOutputPath>
<_MvcRazorOutputFullPath Condition="'$(_MvcRazorOutputFullPath)'==''">$([MSBuild]::EnsureTrailingSlash('$(MvcRazorOutputPath)'))$(AssemblyName).PrecompiledViews.dll</_MvcRazorOutputFullPath>
@ -13,6 +23,7 @@
<ItemGroup Condition="'@(MvcRazorFilesToCompile)' == ''">
<MvcRazorFilesToCompile Include="@(Content)" Condition="'%(Extension)'=='.cshtml'" />
</ItemGroup>
</Target>
<Target
@ -159,6 +170,7 @@
<Target Name="_MvcRazorResolveFilesToCompute"
AfterTargets="ComputeRefAssembliesToPublish"
DependsOnTargets="_ReportRazorSdkCompatibilityError"
Condition="'$(MvcRazorCompileOnPublish)'=='true'">
<PropertyGroup>

Просмотреть файл

@ -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<CoreCLRApplicationTestFixture<ApplicationWithRazorSdkNeitherUsed.Startup>>
{
public RazorSdkNeitherUsedTest_CoreCLR(
CoreCLRApplicationTestFixture<ApplicationWithRazorSdkNeitherUsed.Startup> 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")));
}
}
}
}

Просмотреть файл

@ -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<CoreCLRApplicationTestFixture<ApplicationWithRazorSdkPrecompilationUsed.Startup>>
{
public RazorSdkPrecompilationUsedTest_CoreCLR(
CoreCLRApplicationTestFixture<ApplicationWithRazorSdkPrecompilationUsed.Startup> 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);
}
}
}
}

Просмотреть файл

@ -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<CoreCLRApplicationTestFixture<ApplicationWithRazorSdkUsed.Startup>>
{
public RazorSdkUsedTest_CoreCLR(
CoreCLRApplicationTestFixture<ApplicationWithRazorSdkUsed.Startup> 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);
}
}
}
}

Просмотреть файл

@ -18,6 +18,13 @@
<Compile Include="CoreCLRTests\*.cs" Condition="'$(TargetFramework)'=='netcoreapp2.0' OR '$(TargetFramework)'=='netcoreapp2.1'" />
</ItemGroup>
<ItemGroup>
<None Remove="CoreCLRTests\RazorSdkNeitherUsedTest_CoreCLR.cs" />
<None Remove="CoreCLRTests\RazorSdkPrecompilationUsedTest_CoreCLR.cs" />
<None Remove="Resources\ApplicationWithRazorSdkPrecompilationUsed.Home.Index.txt" />
<None Remove="Resources\ApplicationWithRazorSdkUsed.Home.Index.txt" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting" Version="$(MicrosoftAspNetCoreServerIntegrationTestingPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsolePackageVersion)" />
@ -32,6 +39,9 @@
<ProjectReference Include="..\..\testapps\ApplicationWithCustomInputFiles\ApplicationWithCustomInputFiles.csproj" />
<ProjectReference Include="..\..\testapps\ApplicationWithParseErrors\ApplicationWithParseErrors.csproj" />
<ProjectReference Include="..\..\testapps\ApplicationWithTagHelpers\ApplicationWithTagHelpers.csproj" />
<ProjectReference Include="..\..\testapps\ApplicationWithRazorSdkNeitherUsed\ApplicationWithRazorSdkNeitherUsed.csproj" />
<ProjectReference Include="..\..\testapps\ApplicationWithRazorSdkPrecompilationUsed\ApplicationWithRazorSdkPrecompilationUsed.csproj" />
<ProjectReference Include="..\..\testapps\ApplicationWithRazorSdkUsed\ApplicationWithRazorSdkUsed.csproj" />
<ProjectReference Include="..\..\testapps\PublishWithEmbedViewSources\PublishWithEmbedViewSources.csproj" />
<ProjectReference Include="..\..\testapps\RazorPagesApp\RazorPagesApp.csproj" />
<ProjectReference Include="..\..\testapps\SimpleAppWithAssemblyRename\SimpleAppWithAssemblyRename.csproj" />

Просмотреть файл

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
ApplicationWithRazorSdkPrecompilationUsed.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Hello from Index!
</body>
</html>

Просмотреть файл

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
ApplicationWithRazorSdkUsed.Views, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Hello from Index!
</body>
</html>

Просмотреть файл

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>$(StandardTestAppTfms)</TargetFrameworks>
<!--
Turning off precompilation on will also turn off Razor SDK.
-->
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
<!-- Use a different filename so we can tell the difference -->
<RazorTargetName>ApplicationWithRazorSdkNeitherUsed.Views</RazorTargetName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(MicrosoftAspNetCoreMvcPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="$(MicrosoftAspNetCoreRazorDesignPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(MicrosoftAspNetCoreServerKestrelPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="$(MicrosoftExtensionsConfigurationCommandLinePackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsolePackageVersion)" />
</ItemGroup>
</Project>

Просмотреть файл

@ -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();
}
}
}

Просмотреть файл

@ -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<Startup>()
.Build();
host.Run();
}
}
}

Просмотреть файл

@ -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();
}
}
}

Просмотреть файл

@ -0,0 +1,8 @@
@{
Layout = "../Shared/_Layout.cshtml";
ViewData["Title"] = "About";
}
<h2>@ViewData["Title"].</h2>
<h3>@ViewData["Message"]</h3>
<p>Use this area to provide additional information.</p>

Просмотреть файл

@ -0,0 +1,6 @@
@{
ViewData["Title"] = "Home Page";
}
@GetType().AssemblyQualifiedName
Hello from Index!

Просмотреть файл

@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>
@RenderBody()
</body>
</html>

Просмотреть файл

@ -0,0 +1,2 @@
@using ApplicationWithRazorSdkNeitherUsed
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

Просмотреть файл

@ -0,0 +1,3 @@
@{
Layout = "Shared/_Layout.cshtml";
}

Просмотреть файл

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>$(StandardTestAppTfms)</TargetFrameworks>
<!--
Turning precompilation on will turn off Razor SDK.
-->
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
<!-- Use a different filename so we can tell the difference -->
<RazorTargetName>ApplicationWithRazorSdkPrecompilationUsed.Views</RazorTargetName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(MicrosoftAspNetCoreMvcPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="$(MicrosoftAspNetCoreRazorDesignPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(MicrosoftAspNetCoreServerKestrelPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="$(MicrosoftExtensionsConfigurationCommandLinePackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsolePackageVersion)" />
</ItemGroup>
</Project>

Просмотреть файл

@ -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();
}
}
}

Просмотреть файл

@ -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<Startup>()
.Build();
host.Run();
}
}
}

Просмотреть файл

@ -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();
}
}
}

Просмотреть файл

@ -0,0 +1,8 @@
@{
Layout = "../Shared/_Layout.cshtml";
ViewData["Title"] = "About";
}
<h2>@ViewData["Title"].</h2>
<h3>@ViewData["Message"]</h3>
<p>Use this area to provide additional information.</p>

Просмотреть файл

@ -0,0 +1,6 @@
@{
ViewData["Title"] = "Home Page";
}
@GetType().Assembly.FullName
Hello from Index!

Просмотреть файл

@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>
@RenderBody()
</body>
</html>

Просмотреть файл

@ -0,0 +1,2 @@
@using ApplicationWithRazorSdkPrecompilationUsed
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

Просмотреть файл

@ -0,0 +1,3 @@
@{
Layout = "Shared/_Layout.cshtml";
}

Просмотреть файл

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<!-- The Web SDK turns this on my default. Setting it back to empty to simulate the 2.1 default -->
<MvcRazorCompileOnPublish></MvcRazorCompileOnPublish>
<TargetFrameworks>$(StandardTestAppTfms)</TargetFrameworks>
<!-- This will become the default for 2.1 soon -->
<RazorCompileOnPublish>true</RazorCompileOnPublish>
<!-- Use a different filename so we can tell the difference -->
<RazorTargetName>ApplicationWithRazorSdkUsed.Views</RazorTargetName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(MicrosoftAspNetCoreMvcPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="$(MicrosoftAspNetCoreRazorDesignPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(MicrosoftAspNetCoreServerKestrelPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="$(MicrosoftExtensionsConfigurationCommandLinePackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(MicrosoftExtensionsLoggingConsolePackageVersion)" />
</ItemGroup>
</Project>

Просмотреть файл

@ -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();
}
}
}

Просмотреть файл

@ -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<Startup>()
.Build();
host.Run();
}
}
}

Просмотреть файл

@ -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();
}
}
}

Просмотреть файл

@ -0,0 +1,8 @@
@{
Layout = "../Shared/_Layout.cshtml";
ViewData["Title"] = "About";
}
<h2>@ViewData["Title"].</h2>
<h3>@ViewData["Message"]</h3>
<p>Use this area to provide additional information.</p>

Просмотреть файл

@ -0,0 +1,6 @@
@{
ViewData["Title"] = "Home Page";
}
@GetType().Assembly.FullName
Hello from Index!

Просмотреть файл

@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>
@RenderBody()
</body>
</html>

Просмотреть файл

@ -0,0 +1,2 @@
@using ApplicationWithRazorSdkUsed
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

Просмотреть файл

@ -0,0 +1,3 @@
@{
Layout = "Shared/_Layout.cshtml";
}

Просмотреть файл

@ -15,4 +15,6 @@
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">false</PublicSign>
</PropertyGroup>
<Import Project="..\src\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.props"/>
</Project>