Search code examples
asp.net-mvcrazorvisual-studio-2013msbuildrazorgenerator

How can I bulk set all cshtml MVC views to build action None?


I am using RazorGenerator so don't need to include cshtml files in my deployment as I have the compiled pages. All pages are compiled using Custom Tool RazorGenerator but have their build Action currently set to content. When I package up the solution they get included increasing the size of the deployment.

How can I set 800 cshtml files to BuildAction of None rather than Content? I don't fancy doing it manually. Is there an easy way to bulk exclude with an MSBuild rule etc?


Solution

    • Proj file is valid xml file, you can write simple console app that will read proj file and set value of the build action node.
    • Depending on your project structure, you can select range of cshtml files in the Solution explorer while pressing Shift and set Build action in properties window and set Build Action to None, it will set it for all selected files.