@@ -27,6 +27,10 @@ public async Task Publish_RazorCompileOnPublish_IsDefault()
27
27
Assert . FileExists ( result , PublishOutputPath , "SimpleMvc.Views.dll" ) ;
28
28
Assert . FileExists ( result , PublishOutputPath , "SimpleMvc.Views.pdb" ) ;
29
29
30
+ // Verify assets get published
31
+ Assert . FileExists ( result , PublishOutputPath , "wwwroot" , "js" , "SimpleMvc.js" ) ;
32
+ Assert . FileExists ( result , PublishOutputPath , "wwwroot" , "css" , "site.css" ) ;
33
+
30
34
// By default refs and .cshtml files will not be copied on publish
31
35
Assert . FileCountEquals ( result , 0 , Path . Combine ( PublishOutputPath , "refs" ) , "*.dll" ) ;
32
36
Assert . FileCountEquals ( result , 0 , Path . Combine ( PublishOutputPath , "Views" ) , "*.cshtml" ) ;
@@ -294,6 +298,11 @@ public async Task Publish_WithP2P_AndRazorCompileOnPublish_CopiesRazorAssembly()
294
298
Assert . FileExists ( result , PublishOutputPath , "ClassLibrary.pdb" ) ;
295
299
Assert . FileExists ( result , PublishOutputPath , "ClassLibrary.Views.dll" ) ;
296
300
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" ) ;
297
306
}
298
307
299
308
[ Fact ]
@@ -310,5 +319,40 @@ public async Task Publish_SimpleMvcFSharp_NoopsWithoutFailing()
310
319
Assert . FileDoesNotExist ( result , OutputPath , "SimpleMvcFSharp.Views.dll" ) ;
311
320
Assert . FileDoesNotExist ( result , OutputPath , "SimpleMvcFSharp.Views.pdb" ) ;
312
321
}
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
+ }
313
357
}
314
358
}
0 commit comments