3

I have a resource file MyResource.resx, and I want to change how the MyResource.Designer.cs file gets generated.

I have a t4 script that accepts a resx file as input and gives me the resulting transform, however, I must manually run this t4 in order for it to work.

I see that the "custom tool" property for the resx file is currently specified as PublicResXFileCodeGenerator, I changed it to TextTemplatingFileGenerator, but that only made Visual Studio execute the resx as if it were a t4.

How do I configure my t4 to automatically run on my resource when the resource is changed?

Matthew
  • 24,703
  • 9
  • 76
  • 110

2 Answers2

6

Check this out: AutoRunCustomTool or Download from Visual Studio Gallery

From the readme:

After you install the extension, you should see a new Run custom tool on property on each project item. Just edit this property to add the name(s) of the target file(s). That's it!

"target" files are your .tt files

Orif Khodjaev
  • 1,080
  • 1
  • 13
  • 34
1

There is no good way to have Visual Studio automatically transform templates whenever a resource changes, but MSDN does call out a setting you can add in your project file to transform on build:

https://msdn.microsoft.com/en-us/library/dd820620.aspx#Regenerating

moarboilerplate
  • 1,633
  • 9
  • 23