8

I'm writing my own custom item template for use within visual studio. All is well except I need to find a way to get one of the files in the template to be dependent upon another.

In a csproj file it would look like this

<Compile Include="Class1.cs">
    <DependentUpon>Class1.xml</DependentUpon>
</Compile>

Does anybody have any idea how I would define this in the vstemplate file?

Thanks

David Gardiner
  • 16,892
  • 20
  • 80
  • 117
mat-mcloughlin
  • 6,492
  • 12
  • 45
  • 62

2 Answers2

17
<ProjectItem SubType="Code" TargetFileName="$fileinputname$.cs" ReplaceParameters="true">Test.cs</ProjectItem>
<ProjectItem SubType="Code" TargetFileName="$fileinputname$.cs\$fileinputname$Dependent.cs" ReplaceParameters="true">TestDependent.cs</ProjectItem>
Yasin Kilicdere
  • 426
  • 6
  • 17
0

Not sure if this can happen automatically for non-managed file types (i.e. file types that VS doesn't know about, like yours)...

A hack would be to use WizardExtensions (google for examples on writing a basic wizard) like this:

  • Add the files initially as .cs and .designer.cs.
  • Then use wizardExtensions to rename those files

or

  • see if wizard extensions can directly modify the csproj (but that be difficult as VS might not let you do that without unloading the project first).

hope this helps...

Mrchief
  • 75,126
  • 20
  • 142
  • 189