문제

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

도움이 되었습니까?

해결책

<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>

다른 팁

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...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top