diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.targets b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.targets
index db6a806b50..5fb7dab0e3 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.targets
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.targets
@@ -12,7 +12,7 @@
.Views
-
+
<_Parameter1>$(RazorTargetName)
diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs
index 1f94c08fcb..4dbd856543 100644
--- a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs
+++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/BuildIntegrationTest.cs
@@ -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();