I would like to include the current timestamp as part of my Visual Studio Item Template (the timestamp of when the file is created by the user). Is this possible?
views:
94answers:
2Can I generate values for a custom parameter such as a timstamp for a Visual Studio Item Template?
You can cause code to be executed when a template is expanded by implementing a wizard. The wizard need not have a user interface, but can populate a dictionary of name/value pairs. The values can then be substituted into the template.
Look in the Visual Studio SDK documentation for the topic named "How to: Use Wizards with Project Templates". I believe you can also use a wizard in an item template.
Also, take a look at the Guidance Automation Toolkit, which provides a declarative way to create wizards, among many other things.
It's really simple. There are several built-in replacement parameters that you can use. For a timestamp, include $time$ in the template. It will be replaced by the current date and time in the format DD/MM/YYYY HH:MM:SS.
Check this excellent guide: Create Reusable Project And Item Templates For Your Development Team