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>
|
<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.
|
MVC uses a ProvideApplicationPartFactoryAttribute on the generated assembly to load compiled views from assembly. Set this to false, to prevent generating this attribute.
|
||||||
This results in compiled views being discovered and routes for compiled Razor Pages being set up. Setting this value to false, disables this behavior.
|
|
||||||
-->
|
-->
|
||||||
<EnableDefaultCompiledViewAssemblyLoadBehavior Condition="'$(EnableDefaultCompiledViewAssemblyLoadBehavior)' == ''">true</EnableDefaultCompiledViewAssemblyLoadBehavior>
|
<GenerateProvideApplicationPartFactoryAttribute>true</GenerateProvideApplicationPartFactoryAttribute>
|
||||||
|
|
||||||
<!-- Override for testing. This path is only correct inside a nuget package. -->
|
<!-- 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>
|
<_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.
|
Use the suffix .Views when producing compiled view assemblies. This matches the requirements for Mvc's ViewsFeatureProvider.
|
||||||
-->
|
-->
|
||||||
<RazorTargetNameSuffix Condition="'$(RazorTargetNameSuffix)'==''">.Views</RazorTargetNameSuffix>
|
<RazorTargetNameSuffix Condition="'$(RazorTargetNameSuffix)'==''">.Views</RazorTargetNameSuffix>
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(ProvideApplicationPartFactoryAttributeTypeName)' == ''">
|
<!--
|
||||||
<ProvideApplicationPartFactoryAttributeTypeName Condition="'$(EnableDefaultCompiledViewAssemblyLoadBehavior)'=='false'">Microsoft.AspNetCore.Mvc.ApplicationParts.NullApplicationPartFactory, Microsoft.AspNetCore.Mvc.Core</ProvideApplicationPartFactoryAttributeTypeName>
|
The type name of the ApplicationPartFactory applied to the generated Razor file.
|
||||||
|
-->
|
||||||
<ProvideApplicationPartFactoryAttributeTypeName Condition="'$(EnableDefaultCompiledViewAssemblyLoadBehavior)'=='true'">Microsoft.AspNetCore.Mvc.ApplicationParts.CompiledRazorAssemblyApplicationPartFactory, Microsoft.AspNetCore.Mvc.Razor</ProvideApplicationPartFactoryAttributeTypeName>
|
<ProvideApplicationPartFactoryAttributeTypeName Condition="'$(ProvideApplicationPartFactoryAttributeTypeName)' == ''">Microsoft.AspNetCore.Mvc.ApplicationParts.CompiledRazorAssemblyApplicationPartFactory, Microsoft.AspNetCore.Mvc.Razor</ProvideApplicationPartFactoryAttributeTypeName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(GenerateRazorAssemblyInfo)'=='true' AND '$(ResolvedRazorCompileToolset)'=='RazorSdk' AND ('$(RazorCompileOnBuild)' == 'true' OR '$(RazorCompileOnPublish)' == 'true')">
|
<ItemGroup Condition="'$(GenerateRazorAssemblyInfo)'=='true' AND '$(ResolvedRazorCompileToolset)'=='RazorSdk' AND ('$(RazorCompileOnBuild)' == 'true' OR '$(RazorCompileOnPublish)' == 'true')">
|
||||||
|
|
@ -26,7 +25,7 @@
|
||||||
</AssemblyAttribute>
|
</AssemblyAttribute>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(ProvideApplicationPartFactoryAttributeTypeName)'!=''">
|
<ItemGroup Condition="'$(GenerateProvideApplicationPartFactoryAttribute)' == 'true' AND '$(ProvideApplicationPartFactoryAttributeTypeName)'!=''">
|
||||||
<RazorAssemblyAttribute Include="Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute">
|
<RazorAssemblyAttribute Include="Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute">
|
||||||
<_Parameter1>$(ProvideApplicationPartFactoryAttributeTypeName)</_Parameter1>
|
<_Parameter1>$(ProvideApplicationPartFactoryAttributeTypeName)</_Parameter1>
|
||||||
</RazorAssemblyAttribute>
|
</RazorAssemblyAttribute>
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,21 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
<GenerateRazorAssemblyInfoDependsOn>
|
<GenerateRazorAssemblyInfoDependsOn>
|
||||||
GetRazorAssemblyAttributes;
|
GetRazorAssemblyAttributes;
|
||||||
CreateRazorGeneratedAssemblyInfoInputsCacheFile;
|
CreateRazorGeneratedAssemblyInfoInputsCacheFile;
|
||||||
|
CoreGenerateRazorAssemblyInfo
|
||||||
</GenerateRazorAssemblyInfoDependsOn>
|
</GenerateRazorAssemblyInfoDependsOn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Target
|
<Target
|
||||||
Name="GenerateRazorAssemblyInfo"
|
Name="GenerateRazorAssemblyInfo"
|
||||||
DependsOnTargets="$(GenerateRazorAssemblyInfoDependsOn)"
|
DependsOnTargets="$(GenerateRazorAssemblyInfoDependsOn)"
|
||||||
|
Condition="'$(GenerateRazorTargetAssemblyInfo)'=='true'">
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target
|
||||||
|
Name="CoreGenerateRazorAssemblyInfo"
|
||||||
Inputs="$(_GeneratedRazorAssemblyInfoInputsCacheFile)"
|
Inputs="$(_GeneratedRazorAssemblyInfoInputsCacheFile)"
|
||||||
Outputs="$(GeneratedRazorTargetAssemblyInfo)"
|
Outputs="$(GeneratedRazorTargetAssemblyInfo)"
|
||||||
Condition="'$(GenerateRazorTargetAssemblyInfo)'=='true' AND '@(RazorAssemblyAttribute)'!='' AND '@(RazorCompile)'!=''">
|
Condition="'@(RazorCompile)'!=''">
|
||||||
|
|
||||||
<ItemGroup Condition="'$(GenerateRazorTargetAssemblyInfo)'=='true'">
|
<ItemGroup Condition="'$(GenerateRazorTargetAssemblyInfo)'=='true'">
|
||||||
<!-- Ensure the generated assemblyinfo file is not already part of RazorCompile sources -->
|
<!-- Ensure the generated assemblyinfo file is not already part of RazorCompile sources -->
|
||||||
|
|
|
||||||
|
|
@ -410,15 +410,15 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[InitializeTestProject("ClassLibrary")]
|
[InitializeTestProject("ClassLibrary")]
|
||||||
public async Task Build_UsesNullFactory_IfEnableDefaultCompiledViewAssemblyLoadBehaviorIsSetToFalse()
|
public async Task Build_DoesNotGenerateProvideApplicationPartFactoryAttribute_IfGenerateProvideApplicationPartFactoryAttributeIsUnset()
|
||||||
{
|
{
|
||||||
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorAssemblyInfo.cs");
|
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.BuildPassed(result);
|
||||||
|
|
||||||
Assert.FileExists(result, razorAssemblyInfo);
|
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]
|
[Fact]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue