سؤال

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