Search code examples
c#buildbuild-process

How to modifying a source file "file.cs" using an custom auto-generation tool during build process?


I am creating ResourceDictionarya and i want to create an enum that contain all the target ResourceDictionary Keys, to use in my code, to reduce the typing errors i tried to make a simpe tool.exe and called it in the Pre-build Action, but i am looking for best way to do that, any one help me please. thanks in advance.


Solution

  • Consider using T4 templates to get the job done. A T4 template can generate a C# file and you can configure your build to regenerate the file every time.