OdeToCode IC Logo

SiteMap Macro v2.0

Tuesday, October 17, 2006

Last year I wrote a little macro to generate a web.sitemap file for ASP.NET 2.0. A few people have been asking about support for Web Application Projects, so I've updated the macro.


This macro walks through the directories of a web project and adds all the content pages to a ASP.NET 2.0 site map file. If you use URL re-writing or virtual path providers, it won't be able to see those URLs. Chances are you'll need to hand tweak the file afterwards as the macro isn't intelligent enough to devise a good title for each page, but it can save a lot of typing to get started.

To install:

  1. Open the macro explorer (Alt+F8).
  2. Right click a macro project and select "New Moduleā€¦"
  3. Name the new module SiteMapMacro
  4. Right click the new module and select "Edit". Clear existing code.
  5. Paste the code from the download into the new file.
  6. In the Project Explorer, right click References and add a reference to System.Xml.dll. Close the editor.

Back in the macro explorer, you should be able to right-click the macro to execute it.

Russian Geek Wednesday, October 18, 2006
New module or new macro? Otherwise, how can I run a module?

Thank you in advance.
scott Wednesday, October 18, 2006

The download is a complete module. Once it is installed you should be able to expand (+) the module in Macro Explorer and right click to run the macro inside.
Fabrizio Ferrari Wednesday, November 29, 2006
I modified this function because the project.Kind is the same for Web Apps and ordinary projects. In this way the project is correctly recognized.

Private Function IsWebProject(ByVal project As EnvDTE.Project) As Boolean

Dim extenderNames As String() = CType(project.ExtenderNames, String())

If project.Kind.ToUpper() = webSiteProjectGuid Then
isWebAppProject = False
Return True
End If

If extenderNames.Length > 0 AndAlso extenderNames(0) = "WebApplication" Then
isWebAppProject = True
Return True
End If

Return False

End Function
Comments are closed.