RazorGenerator
RazorGenerator copied to clipboard
Is there a way to automatically set the Custom Tool for new views?
When we add a new view, someone may forget to set the custom tool portion, is it possible to automate those?
I thought the NuGet command Enable-RazorGenerator does this automatically - it sets the Custom Tool to "RazorGenerator" on every .cshtml file in the current project.
I do wish the same command would also set the Build Action to None so that the files aren't deployed, but that's another ask.
This is not to be confused with Redo-RazorGenerator which simply re-generates all .generated.cs files for each .cshtml file already marked with the RazorGenerator Custom Tool.
There might be DTE events that we could hook on to observe new file events, but I'm not super familiar with that API. If you have any leads on how we'd do it (short of re-running Enable-RazorGenerator), we'd be happy to take a pull request.
interface EnvDTE.ProjectItemsEvents has the ItemAdded event.
Here's an example using the interface, though it doesn't use the ItemAdded events: http://stackoverflow.com/questions/3471511/where-should-i-attach-solution-or-project-events-in-my-visual-studio-add-in
Googling for "envdte itemadded" shows more examples.