Merge pull request #2212 from aspnet/release/2.1
Remove EnableDefaultCompiledViewAssemblyLoadBehavior and add a switch…
This commit is contained in:
commit
cb3d797f46
|
|
@ -12,10 +12,9 @@
|
|||
<RazorDefaultConfiguration Condition="'$(RazorDefaultConfiguration)'==''">MVC-2.1</RazorDefaultConfiguration>
|
||||
|
||||
<!--
|
||||
Determines the load behavior for Razor compiled views in an Mvc application. By default, the compiled assembly is initialized as an Mvc application part.
|
||||
This results in compiled views being discovered and routes for compiled Razor Pages being set up. Setting this value to false, disables this behavior.
|
||||
MVC uses a ProvideApplicationPartFactoryAttribute on the generated assembly to load compiled views from assembly. Set this to false, to prevent generating this attribute.
|
||||
-->
|
||||
<EnableDefaultCompiledViewAssemblyLoadBehavior Condition="'$(EnableDefaultCompiledViewAssemblyLoadBehavior)' == ''">true</EnableDefaultCompiledViewAssemblyLoadBehavior>
|
||||
<GenerateProvideApplicationPartFactoryAttribute>true</GenerateProvideApplicationPartFactoryAttribute>
|
||||
|
||||
<!-- Override for testing. This path is only correct inside a nuget package. -->
|
||||
<_MvcExtensionAssemblyPath Condition="'$(_MvcExtensionAssemblyPath)'==''">$(MSBuildThisFileDirectory)..\..\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll</_MvcExtensionAssemblyPath>
|
||||
|
|
|
|||
|
|
@ -12,12 +12,11 @@
|
|||
Use the suffix .Views when producing compiled view assemblies. This matches the requirements for Mvc's ViewsFeatureProvider.
|
||||
-->
|
||||
<RazorTargetNameSuffix Condition="'$(RazorTargetNameSuffix)'==''">.Views</RazorTargetNameSuffix>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(ProvideApplicationPartFactoryAttributeTypeName)' == ''">
|
||||
<ProvideApplicationPartFactoryAttributeTypeName Condition="'$(EnableDefaultCompiledViewAssemblyLoadBehavior)'=='false'">Microsoft.AspNetCore.Mvc.ApplicationParts.NullApplicationPartFactory, Microsoft.AspNetCore.Mvc.Core</ProvideApplicationPartFactoryAttributeTypeName>
|
||||
|
||||
<ProvideApplicationPartFactoryAttributeTypeName Condition="'$(EnableDefaultCompiledViewAssemblyLoadBehavior)'=='true'">Microsoft.AspNetCore.Mvc.ApplicationParts.CompiledRazorAssemblyApplicationPartFactory, Microsoft.AspNetCore.Mvc.Razor</ProvideApplicationPartFactoryAttributeTypeName>
|
||||
<!--
|
||||
The type name of the ApplicationPartFactory applied to the generated Razor file.
|
||||
-->
|
||||
<ProvideApplicationPartFactoryAttributeTypeName Condition="'$(ProvideApplicationPartFactoryAttributeTypeName)' == ''">Microsoft.AspNetCore.Mvc.ApplicationParts.CompiledRazorAssemblyApplicationPartFactory, Microsoft.AspNetCore.Mvc.Razor</ProvideApplicationPartFactoryAttributeTypeName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(GenerateRazorAssemblyInfo)'=='true' AND '$(ResolvedRazorCompileToolset)'=='RazorSdk' AND ('$(RazorCompileOnBuild)' == 'true' OR '$(RazorCompileOnPublish)' == 'true')">
|
||||
|
|
@ -26,7 +25,7 @@
|
|||
</AssemblyAttribute>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(ProvideApplicationPartFactoryAttributeTypeName)'!=''">
|
||||
<ItemGroup Condition="'$(GenerateProvideApplicationPartFactoryAttribute)' == 'true' AND '$(ProvideApplicationPartFactoryAttributeTypeName)'!=''">
|
||||
<RazorAssemblyAttribute Include="Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute">
|
||||
<_Parameter1>$(ProvideApplicationPartFactoryAttributeTypeName)</_Parameter1>
|
||||
</RazorAssemblyAttribute>
|
||||
|
|
|
|||
|
|
@ -27,15 +27,21 @@ Copyright (c) .NET Foundation. All rights reserved.
|
|||
<GenerateRazorAssemblyInfoDependsOn>
|
||||
GetRazorAssemblyAttributes;
|
||||
CreateRazorGeneratedAssemblyInfoInputsCacheFile;
|
||||
CoreGenerateRazorAssemblyInfo
|
||||
</GenerateRazorAssemblyInfoDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target
|
||||
Name="GenerateRazorAssemblyInfo"
|
||||
DependsOnTargets="$(GenerateRazorAssemblyInfoDependsOn)"
|
||||
Condition="'$(GenerateRazorTargetAssemblyInfo)'=='true'">
|
||||
</Target>
|
||||
|
||||
<Target
|
||||
Name="CoreGenerateRazorAssemblyInfo"
|
||||
Inputs="$(_GeneratedRazorAssemblyInfoInputsCacheFile)"
|
||||
Outputs="$(GeneratedRazorTargetAssemblyInfo)"
|
||||
Condition="'$(GenerateRazorTargetAssemblyInfo)'=='true' AND '@(RazorAssemblyAttribute)'!='' AND '@(RazorCompile)'!=''">
|
||||
Condition="'@(RazorCompile)'!=''">
|
||||
|
||||
<ItemGroup Condition="'$(GenerateRazorTargetAssemblyInfo)'=='true'">
|
||||
<!-- Ensure the generated assemblyinfo file is not already part of RazorCompile sources -->
|
||||
|
|
|
|||
|
|
@ -410,15 +410,15 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
|||
|
||||
[Fact]
|
||||
[InitializeTestProject("ClassLibrary")]
|
||||
public async Task Build_UsesNullFactory_IfEnableDefaultCompiledViewAssemblyLoadBehaviorIsSetToFalse()
|
||||
public async Task Build_DoesNotGenerateProvideApplicationPartFactoryAttribute_IfGenerateProvideApplicationPartFactoryAttributeIsUnset()
|
||||
{
|
||||
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorAssemblyInfo.cs");
|
||||
var result = await DotnetMSBuild("Build", "/p:EnableDefaultCompiledViewAssemblyLoadBehavior=false");
|
||||
var result = await DotnetMSBuild("Build", "/p:GenerateProvideApplicationPartFactoryAttribute=false");
|
||||
|
||||
Assert.BuildPassed(result);
|
||||
|
||||
Assert.FileExists(result, razorAssemblyInfo);
|
||||
Assert.FileContains(result, razorAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute(\"Microsoft.AspNetCore.Mvc.ApplicationParts.NullApplicationPartFactory");
|
||||
Assert.FileDoesNotContain(result, razorAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
Loading…
Reference in New Issue