views:

113

answers:

2

To explain a little more, I have a file Sidebar.cs, and I have Sidebar.js, and Sidebar.css.

I would like to be able to make it Sidebar.cs, Sidebar.cs.js, and Sidebar.cs.css, and have the js and css file go "under" (as children of) the Sidebar.cs node in the treeview, just like what happens with .designer files and .aspx.cs files.

Is this possible to accomplish?

+2  A: 

Open up the project file in a text editor or using the "edit project file" context menu (might be only part of an add-in I have). You can then use the DependentUpon XML tag to get the hierarchy. For example, this is how a Form and it's designer look:

<Compile Include="Views\SSWizardForm.cs">
  <SubType>Form</SubType>
</Compile>
<Compile Include="Views\SSWizardForm.designer.cs">
  <DependentUpon>SSWizardForm.cs</DependentUpon>
</Compile>

Note the "DependentUpon" tag, meaning "make this a child of another file".

ctacke
Do you know if there is any way to make it do this automatically? Could I create a file template that does this without having to manually do it every time?
Max Schmeling
There must be a way, since Studio does it when you create a Form, but I've not taken the time to figure out how.
ctacke
FYI this doesn't work when you're using it for multiple resource files like i am, because it tries to give them all the same name (the name of the thing they're dependent upon, which isn't allowed) :( bummer
Max Schmeling
It should still work fine - I have files with 4 or 5 children. All have to have unique names (typically extension) and you have to select one to be the parent.
ctacke
you can use VSCommands addin to do it directly from Visual Studio without a need to edit project files http://visualstudiogallery.msdn.microsoft.com/en-us/d491911d-97f3-4cf6-87b0-6a2882120acf
jarek
A: 

I haven't tried this myself, so take this with a pinch of salt, but this is what I infer by looking at projects I have to hand

Open the project file in notepad (or other preferred text editor), and the structure of a project file so it looks like

<Compile Include="whatever.cs">
  <DependentUpon>whatever.else</DependentUpon>
</Compile>
<None Include="whatever.else" />

instead of

<Compile Include="whatever.cs" />

with as many DependentUpon clauses and None elements as needed

Steve Gilham