RazorGenerator icon indicating copy to clipboard operation
RazorGenerator copied to clipboard

Is there a way to automatically set the Custom Tool for new views?

Open fakedevil opened this issue 9 years ago • 3 comments

When we add a new view, someone may forget to set the custom tool portion, is it possible to automate those?

fakedevil avatar Dec 03 '15 00:12 fakedevil

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.

daiplusplus avatar Sep 13 '16 20:09 daiplusplus

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.

pranavkm avatar Sep 13 '16 20:09 pranavkm

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.

daiplusplus avatar Sep 13 '16 21:09 daiplusplus