Friday, October 19, 2007

Set the "Custom Tool" property for a project file.

Recently I came across the need to create a custom tool that codegen a string resource from an xml file. The problem that i got into was to find a way to set the "Custom Tool" property of the xml file. Below is the code that I used after spending some effort in searching. I hope this can help to save some of your time too. If you want to know what other properties are in, you can loop through the collection.

31 public void Execute(object Application, int hwndOwner, ref object[] ContextParams, ref object[] CustomParams, ref EnvDTE.wizardResult retval)

32 {

33 //If you want to create project, code should be included in this function.

34 ProjectItems projectItems = (ProjectItems)ContextParams[2];

35 ProjectItem projectItemXML = projectItems.AddFromTemplate((string)CustomParams[0] + "\\StringResourceTemplate.xml", (string)ContextParams[4] + ".xml");


37 projectItemXML.Properties.Item("CustomTool").Value = "StringResourceGenerator";

No comments: