VS Item Template Compiled Custom Parameter
-
11-09-2019 - |
Question
I would like to create a custom parameter for a vstemplate containing some C# code. Basically I want to put DateTime.Now.ToString("yyyyMMddHHmmssfff")
in my template (the formatted date, not the code). Basically I want to achieve the equivalent of the T4 below in my item template.
[Migration(<#= DateTime.Now.ToString("yyyyMMddHHmmssfff") #>)]
public class $fileinputname$ : Migration
Is this possible? Or is there a simple way to use a T4 as the template file for my vstemplate item?
Solution 2
There is no way to accomplish this with standard VSTemplates. In order to get C# output in to your template you need to create a wizard so you can populate your own parameters for the templates.
OTHER TIPS
I do not believe that there is any way to add a date in that format using visual studio templates. According to the MSDN documentation, your only date/time options are YYYY
and DD/MM/YYYY 00:00:00
.
You can do this is in code templates. I think this is what you're after: http://theoldsewingfactory.wordpress.com/2010/03/04/code-templates-for-migratordotnet/