How to set the Custom Tool property programmatically from a VS package?

Hi,

I am writing a VS package using the cool new VSIP for Visual Studio 2005. My question is how can I set the custom tool property of an item? It does not seem to be defined as a VSHPROPID_xxxx?

Thanks.

[208 byte] By [SimonMourier] at [2008-1-10]
# 1
Hi you might want to ask this question over here:
http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=57

it is the extensibility board, where the VSIP folk hang out ;)

PaulPaschedag at 2007-10-3 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 2

Thanks Paul,

I eventually found out a solution described here http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=54651. I have modified the CS.vstemplate file this way:

<!--DSL Tools Language Template-->
<VSTemplate Version="2.0.0" Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<TemplateData>
<Name Package="{430bba70-950a-4eae-bea9-a0d43e8d5867}" ID="100"/>
<Description Package="{430bba70-950a-4eae-bea9-a0d43e8d5867}" ID="102"/>
<Icon Package="{430bba70-950a-4eae-bea9-a0d43e8d5867}" ID="401" />
<ProjectType>CSharp</ProjectType>
<SortOrder>1</SortOrder>
<DefaultName>CodeFluentLanguage.cfml</DefaultName>
<AppendDefaultFileExtension>true</AppendDefaultFileExtension>
</TemplateData>
<TemplateContent>
<ProjectItem ReplaceParameters="true">cfml.cfml</ProjectItem>
<CustomParameters>
<CustomParameter Name="$CustomTool$" Value="CfmlGenerator" />
</CustomParameters>
</TemplateContent>
</VSTemplate>

Note the ReplaceParameters="true" attribute and CustomParameters section (CfmlGenerator is my own IVSSingleFileGenerator). But it does not seem to work (althought I have regenerated all templates and rebuilt the solution), and I don't know why.

I also found a programmatic way of doing it using the IVsEditorFactoryNotify interface, implementing the NotifyItemAdded method, and modifying the EditorFactory.dslddt (or EditorFactory.dslddi). This works great! If some people are interested I may drop a note on how to do it.

Thanks again.

SimonMourier at 2007-10-3 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 3

Hi Simon,

Simon Mourier wrote:

This works great! If some people are interested I may drop a note on how to do it.

Please drop it. Thanks in advance!

DmitryPavlov at 2007-10-3 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 4

Hi Dmitry,

You can check out the related article here http://www.codeproject.com/cs/library/DSLTools.asp

It's the full description of what we have put in place (not only related to DSL tools, but to the VS SDK as well).

SimonMourier at 2007-10-3 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 5

Thank you, Simon!

Will dig into the article you recommended.

DmitryPavlov at 2007-10-3 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 6

There's another way of doing it. See the code sample below:

ProjectItems projectItems = (ProjectItems)ContextParams[2];

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

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

cheers.

leonwoo at 2007-10-3 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...

Visual Studio

Site Classified