none
Nesting Related Files

    Question

  • Hi there,

    Unlike many users of ASP.NET solutions, I am building my websites using XML/XSL transformations.
    Because of that, I have lot of XML and XSL files in the same location as the aspx and its related code behind files.

    For the overview of it, i have named my XML/XSLT files the same as the aspx file, for an exampe: default.aspx would be named default.aspx.xml, default.aspx.xsl.

    Since there is already an option in VS2005 for nesting related files, i was wondering if ít has been so smartly developed, so i might add my own "related" files to this already built-in functionality?

    This would really ease up my overview.  

    Thanks in advance for usefull feedback regarding this matter :)

    Saturday, November 11, 2006 3:17 AM

Answers

  • Hi Michael.

    For web projects these relationships are stored in the registry and is extensible. Here's some information on how to do that:

     

     Defining Related Files

    The web project system has the ability to nest one file type under another file type in the solution explorer.  These relationships are all done by pattern matching the file names and are driven by entries under the RelatedFiles key.

    HKLM\Microsoft\VisualStudio\8.0\

    {

        NoRemove 'Projects'

        {

             NoRemove '{E24C65DC-7377-472b-9ABA-BC803B73C61A}' = s '#2143'

             {                   {

    RelatedFiles

    {

    .PrimaryExtension

    {

    val 'RelationType' = d 'typeValue'

                val ‘Suffix’ = s ’somesuffix’

                .RelatedExt1

                .RelatedExt2

                .RelatedExtn

    }

    }

              }

         }

    }

     

    PrimaryExtension      This is the extension of the “primary” file – the one that will contain the nested files.

     

    RelationType             This value defines the pattern that is used to form the relationship. The supported typeValue’s are:

                                    

    Value = 1 – this defines a simple relationship based on the base name of the parent file.  basename.PrimaryExtension  will have one or more related files called basename.RelatedExt1, basename.RelatedExt2, etc.

     

    e.g. foo.xsd

                   foo.xsx

                   foo.xsc

     

    Value = 2 – this defines a basename.primaryextension to basename.primaryext.relatedextension relationship.  

     

    e.g. foo.aspx

                   foo.aspx.vb

     

     

    Suffix                         Optional. Only used by the simple relationship (RelationType = 1), to extend the simple relationship to include semi-colon delimited list of possible suffixes to the base name.  If Suffix was set to ‘_bar;_foobar’,  the simple relationship example above becomes:

     

                                        foo.xsd

                                                    foo_bar.xsx

                                                    foo_bar.xsc

                                                    foo_foobar.xsx

                                                    foo_foobar.xsc

                                     To include foo.xsx and foo.xsc as well as the suffix varieties, one of the suffixes needs to be the empty string as denoted by the leading semi-colon:  ‘;_bar;foobar’

     

    .RelatedExt1…n         The file extensions which will appear under the primary file.  In the example above, it would register two extensions .xsx, and .xsc.

     

    Monday, November 27, 2006 10:27 PM

All replies

  • Hi Michael.

    For web projects these relationships are stored in the registry and is extensible. Here's some information on how to do that:

     

     Defining Related Files

    The web project system has the ability to nest one file type under another file type in the solution explorer.  These relationships are all done by pattern matching the file names and are driven by entries under the RelatedFiles key.

    HKLM\Microsoft\VisualStudio\8.0\

    {

        NoRemove 'Projects'

        {

             NoRemove '{E24C65DC-7377-472b-9ABA-BC803B73C61A}' = s '#2143'

             {                   {

    RelatedFiles

    {

    .PrimaryExtension

    {

    val 'RelationType' = d 'typeValue'

                val ‘Suffix’ = s ’somesuffix’

                .RelatedExt1

                .RelatedExt2

                .RelatedExtn

    }

    }

              }

         }

    }

     

    PrimaryExtension      This is the extension of the “primary” file – the one that will contain the nested files.

     

    RelationType             This value defines the pattern that is used to form the relationship. The supported typeValue’s are:

                                    

    Value = 1 – this defines a simple relationship based on the base name of the parent file.  basename.PrimaryExtension  will have one or more related files called basename.RelatedExt1, basename.RelatedExt2, etc.

     

    e.g. foo.xsd

                   foo.xsx

                   foo.xsc

     

    Value = 2 – this defines a basename.primaryextension to basename.primaryext.relatedextension relationship.  

     

    e.g. foo.aspx

                   foo.aspx.vb

     

     

    Suffix                         Optional. Only used by the simple relationship (RelationType = 1), to extend the simple relationship to include semi-colon delimited list of possible suffixes to the base name.  If Suffix was set to ‘_bar;_foobar’,  the simple relationship example above becomes:

     

                                        foo.xsd

                                                    foo_bar.xsx

                                                    foo_bar.xsc

                                                    foo_foobar.xsx

                                                    foo_foobar.xsc

                                     To include foo.xsx and foo.xsc as well as the suffix varieties, one of the suffixes needs to be the empty string as denoted by the leading semi-colon:  ‘;_bar;foobar’

     

    .RelatedExt1…n         The file extensions which will appear under the primary file.  In the example above, it would register two extensions .xsx, and .xsc.

     

    Monday, November 27, 2006 10:27 PM
  • Thank you very much for this - very helpfull and the solution to my challenge ;)
    Tuesday, December 5, 2006 5:19 PM
  • What if non-web project?

     

    Thanks,

    Michael

    Tuesday, November 13, 2007 8:27 AM
  • Hi Michael,

    Non-web C# projects use DependentUpon tag in the project file. For example:

    Primary file:


        <Compile Include="ProjectProperties\ReferencePathsPropertyPage.cs">
          <SubType>UserControl</SubType>
        </Compile>


    Secondary files:


        <Compile Include="ProjectProperties\ReferencePathsPropertyPage.Designer.cs">
          <DependentUpon>ReferencePathsPropertyPage.cs</DependentUpon>
        </Compile>

        <EmbeddedResource Include="ProjectProperties\ReferencePathsPropertyPage.resx">
          <SubType>Designer</SubType>
          <DependentUpon>ReferencePathsPropertyPage.cs</DependentUpon>
        </EmbeddedResource>


    Hope that helps,
    Tuesday, January 15, 2008 7:30 AM
    Moderator
  • My familiarity with the registry is limited, could you perhaps post a screen shot, or a key tree that shows what this should look like once its completed. I can't seem to get it to work. I am using Visual Studio 2008.

     

    I am referring to the web project informaiton.

    Tuesday, January 15, 2008 7:10 PM
  • If you are creating a managed package you can use a registration attribute from the MPF (Managed Package Framework) dedicated that specific purpose. If you open the IronPython sample provided in the VSSDK and then look for the class  WebSiteProjectRelatedFilesAttribute. You can reference this file in you project and decorate you package class with this attribute. The file header contains the following sample

     

    /// As an example the following Attribute definition

    /// [WebSiteProjectRelatedFiles("aspx","py")]

    ///

    /// would add the following registry key:

    /// [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\(*version*)\Projects\

    /// {E24C65DC-7377-472B-9ABA-BC803B73C61A}\RelatedFiles\.aspx\.py

    /// "Default"=""

     

     

    Ole

    Tuesday, January 15, 2008 9:27 PM
  • ok I managed to create the following registry keys, and its still not working.

     

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Projects]

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Projects\{E24C65DC-7377-472B-9ABA-BC803B73C61A}]
    @="#2143"

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Projects\{E24C65DC-7377-472B-9ABA-BC803B73C61A}\RelatedFiles]
    @=""

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Projects\{E24C65DC-7377-472B-9ABA-BC803B73C61A}\RelatedFiles\.aspx]
    "RelationType"=dword:00000002
    @=""

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Projects\{E24C65DC-7377-472B-9ABA-BC803B73C61A}\RelatedFiles\.aspx\.js]
    @=""


     

    I hope I did something wrong this has me stumped. Appreciate the help.
    Tuesday, January 15, 2008 11:03 PM
  • Hi,

    Did you resolve this problem?

    I also encounter this issue in VS2010. If you solve this problem, can you give me a hint. I have create all the registry keys.

     

    Thanks in advance:)

    Thursday, May 13, 2010 9:21 AM