Avoid generating RelatedAssemblyAttribute when RazorSdk isn't in play
This commit is contained in:
parent
9fc6b8fcf5
commit
425724ce28
|
|
@ -12,7 +12,7 @@
|
|||
<RazorTargetNameSuffix Condition="'$(RazorTargetNameSuffix)'==''">.Views</RazorTargetNameSuffix>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(GenerateRazorAssemblyInfo)'=='true'">
|
||||
<ItemGroup Condition="'$(GenerateRazorAssemblyInfo)'=='true' AND '$(ResolvedRazorCompileToolset)'=='RazorSdk' AND ('$(RazorCompileOnBuild)' == 'true' OR '$(RazorCompileOnPublish)' == 'true')">
|
||||
<AssemblyAttribute Include="Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute">
|
||||
<_Parameter1>$(RazorTargetName)</_Parameter1>
|
||||
</AssemblyAttribute>
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
|||
Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute(\"Microsoft.AspNetCore.Mvc.ApplicationParts.CompiledRazorAssemblyApplicationPartFac\"");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Fact]
|
||||
[InitializeTestProject("SimpleMvc")]
|
||||
public async Task Build_AddsApplicationPartAttributes_WhenEnableDefaultRazorTargetAssemblyInfoAttributes_IsFalse()
|
||||
{
|
||||
|
|
@ -367,6 +367,51 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
|||
Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute(\"Microsoft.AspNetCore.Mvc.ApplicationParts.CompiledRazorAssemblyApplicationPartFac\"");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[InitializeTestProject("SimpleMvc")]
|
||||
public async Task Build_DoesNotAddRelatedAssemblyPart_IfToolSetIsNotRazorSdk()
|
||||
{
|
||||
var assemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs");
|
||||
var result = await DotnetMSBuild("Build", "/p:RazorCompileToolSet=MvcPrecompilation");
|
||||
|
||||
Assert.BuildPassed(result);
|
||||
|
||||
Assert.FileExists(result, assemblyInfo);
|
||||
Assert.FileDoesNotContain(result, assemblyInfo, "RelatedAssemblyAttribute");
|
||||
|
||||
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[InitializeTestProject("SimpleMvc")]
|
||||
public async Task Build_DoesNotAddRelatedAssemblyPart_IfViewCompilationIsDisabled()
|
||||
{
|
||||
var assemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs");
|
||||
var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=false /p:RazorCompileOnPublish=false");
|
||||
|
||||
Assert.BuildPassed(result);
|
||||
|
||||
Assert.FileExists(result, assemblyInfo);
|
||||
Assert.FileDoesNotContain(result, assemblyInfo, "RelatedAssemblyAttribute");
|
||||
|
||||
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[InitializeTestProject("SimpleMvc")]
|
||||
public async Task Build_AddsRelatedAssemblyPart_IfCompileOnPublishIsAllowed()
|
||||
{
|
||||
var assemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs");
|
||||
var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=false");
|
||||
|
||||
Assert.BuildPassed(result);
|
||||
|
||||
Assert.FileExists(result, assemblyInfo);
|
||||
Assert.FileContains(result, assemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute(\"SimpleMvc.Views\")]");
|
||||
|
||||
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
|
||||
}
|
||||
|
||||
private static DependencyContext ReadDependencyContext(string depsFilePath)
|
||||
{
|
||||
var reader = new DependencyContextJsonReader();
|
||||
|
|
|
|||
Loading…
Reference in New Issue