@@ -27,6 +27,10 @@ public async Task Publish_RazorCompileOnPublish_IsDefault()
2727 Assert . FileExists ( result , PublishOutputPath , "SimpleMvc.Views.dll" ) ;
2828 Assert . FileExists ( result , PublishOutputPath , "SimpleMvc.Views.pdb" ) ;
2929
30+ // Verify assets get published
31+ Assert . FileExists ( result , PublishOutputPath , "wwwroot" , "js" , "SimpleMvc.js" ) ;
32+ Assert . FileExists ( result , PublishOutputPath , "wwwroot" , "css" , "site.css" ) ;
33+
3034 // By default refs and .cshtml files will not be copied on publish
3135 Assert . FileCountEquals ( result , 0 , Path . Combine ( PublishOutputPath , "refs" ) , "*.dll" ) ;
3236 Assert . FileCountEquals ( result , 0 , Path . Combine ( PublishOutputPath , "Views" ) , "*.cshtml" ) ;
@@ -294,6 +298,11 @@ public async Task Publish_WithP2P_AndRazorCompileOnPublish_CopiesRazorAssembly()
294298 Assert . FileExists ( result , PublishOutputPath , "ClassLibrary.pdb" ) ;
295299 Assert . FileExists ( result , PublishOutputPath , "ClassLibrary.Views.dll" ) ;
296300 Assert . FileExists ( result , PublishOutputPath , "ClassLibrary.Views.pdb" ) ;
301+
302+ // Verify fix for https://github.com/aspnet/Razor/issues/2295. No cshtml files should be published from the app
303+ // or the ClassLibrary.
304+ Assert . FileCountEquals ( result , 0 , Path . Combine ( PublishOutputPath , "refs" ) , "*.dll" ) ;
305+ Assert . FileCountEquals ( result , 0 , Path . Combine ( PublishOutputPath , "Views" ) , "*.cshtml" ) ;
297306 }
298307
299308 [ Fact ]
@@ -310,5 +319,40 @@ public async Task Publish_SimpleMvcFSharp_NoopsWithoutFailing()
310319 Assert . FileDoesNotExist ( result , OutputPath , "SimpleMvcFSharp.Views.dll" ) ;
311320 Assert . FileDoesNotExist ( result , OutputPath , "SimpleMvcFSharp.Views.pdb" ) ;
312321 }
322+
323+ [ Fact ]
324+ [ InitializeTestProject ( "SimpleMvc" ) ]
325+ public async Task Publish_DoesNotPublishCustomRazorGenerateItems ( )
326+ {
327+ var additionalProjectContent = @"
328+ <PropertyGroup>
329+ <EnableDefaultRazorGenerateItems>false</EnableDefaultRazorGenerateItems>
330+ </PropertyGroup>
331+ <ItemGroup>
332+ <RazorGenerate Include=""Views\_ViewImports.cshtml"" />
333+ <RazorGenerate Include=""Views\Home\Index.cshtml"" />
334+ </ItemGroup>
335+ " ;
336+ AddProjectFileContent ( additionalProjectContent ) ;
337+ var result = await DotnetMSBuild ( "Publish" ) ;
338+
339+ Assert . BuildPassed ( result ) ;
340+
341+ Assert . FileExists ( result , PublishOutputPath , "SimpleMvc.dll" ) ;
342+ Assert . FileExists ( result , PublishOutputPath , "SimpleMvc.pdb" ) ;
343+ Assert . FileExists ( result , PublishOutputPath , "SimpleMvc.Views.dll" ) ;
344+ Assert . FileExists ( result , PublishOutputPath , "SimpleMvc.Views.pdb" ) ;
345+
346+ // Verify assets get published
347+ Assert . FileExists ( result , PublishOutputPath , "wwwroot" , "js" , "SimpleMvc.js" ) ;
348+ Assert . FileExists ( result , PublishOutputPath , "wwwroot" , "css" , "site.css" ) ;
349+
350+ // By default refs and .cshtml files will not be copied on publish
351+ Assert . FileCountEquals ( result , 0 , Path . Combine ( PublishOutputPath , "refs" ) , "*.dll" ) ;
352+ // Custom RazorGenerate item does not get published
353+ Assert . FileDoesNotExist ( result , PublishOutputPath , "Views" , "Home" , "Home.cshtml" ) ;
354+ // cshtml Content item that's not part of RazorGenerate gets published.
355+ Assert . FileExists ( result , PublishOutputPath , "Views" , "Home" , "About.cshtml" ) ;
356+ }
313357 }
314358}
0 commit comments