有没有办法在Visual Studio Solution Explorer中自定义“分组”文件?

时间:2009-07-29 16:27:41

标签: visual-studio visual-studio-2005 solution-explorer

为了解释一下,我有一个文件Sidebar.cs,我有Sidebar.js和Sidebar.css。

我希望能够将它设置为Sidebar.cs,Sidebar.cs.js和Sidebar.cs.css,并使js和css文件位于Sidebar.cs节点的“下”(作为子节点)在树视图中,就像.designer文件和.aspx.cs文件一样。

这有可能实现吗?

2 个答案:

答案 0 :(得分:3)

在文本编辑器中打开项目文件或使用“编辑项目文件”上下文菜单(可能只是我的加载项的一部分)。然后,您可以使用DependentUpon XML标记来获取层次结构。例如,这就是Form及其设计者的外观:

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

请注意“DependentUpon”标记,表示“将其设为另一个文件的子项”。

答案 1 :(得分:0)

我自己没有试过这个,所以请用一点盐来考虑这个,但这是我通过查看我必须提交的项目推断的

在记事本(或其他首选文本编辑器)中打开项目文件,以及项目文件的结构,使其看起来像

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

而不是

<Compile Include="whatever.cs" />

根据需要添加DependentUpon个子句和None个元素