Visual Studio custom template files, question about DependentUpon

  • Thread starter Lasse Vågsæther Karlsen
  • Start date
L

Lasse Vågsæther Karlsen

Sorry for crossposting this to two newsgroups, I assume the most
appropriate one is one of the vstudio ones, but csharp always have so
many more people so I hope this increases the chance of someone knowing
the answer.

I am trying to build a multi-file item template for my C# projects which
include the following files:

Controller.cs
Controller.Designer.cs
Controller.Interfaces.cs
Controller.Validation.cs

What I'd like is for the three bottommost files to be "beneath" the top
one, like Controller.Designer is.

Basically, after adding the above four files, my project contains this:

Controller1.cs
+- Controller1.Designer.cs
Controller1.Interfaces.cs
Controller1.Validation.cs

What I'd like is for the two bottom files to also be beneath, like this:

Controller1.cs
+- Controller1.Designer.cs
+- Controller1.Interfaces.cs
+- Controller1.Validation.cs

Now, I can go into the .csproj file, which contains the following entries:

<Compile Include="Test\Controller1.cs" />
<Compile Include="Test\Controller1.Designer.cs">
<DependentUpon>Controller1.cs</DependentUpon>
</Compile>
<Compile Include="Test\Controller1.Validation.cs" />
<Compile Include="Test\Controller1.Interfaces.cs" />

I can easily tweak the .csproj file by adding the <DependentUpon> tag
for the other two files as well, but my question is if I can do this
through the .vstemplate file.

This is the current contents of the .vstemplate file, at least the part
listing those files:

<ProjectItem ReplaceParameters="true" OpenInEditor="true">
Controller.cs
</ProjectItem>
<ProjectItem ReplaceParameters="true"
TargetFileName="$fileinputname$.Validation.cs" SubType="Validation">
Controller.Validation.cs
</ProjectItem>
<ProjectItem ReplaceParameters="true"
TargetFileName="$fileinputname$.Interfaces.cs" SubType="Interfaces">
Controller.Interfaces.cs
</ProjectItem>
<ProjectItem ReplaceParameters="true"
TargetFileName="$fileinputname$.Designer.cs" SubType="Designer">
Controller.Designer.cs
</ProjectItem>

Adding a sub-node of <DependentUpon> just gives me an error message
about an invalid path.

Is there anything I can do to my .vstemplate file that would give me the
right nodes in the .csproj file without having to manually tweak it?
 
M

Michel LAPLANE \(MVP\)

I suspect that the dependent upon is only for file managed automatically
with the visual sutiod designer. Think of using Folder in your vstemplate
and csproj.
hope this can help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top