Search code examples
c#parsingvdproj

.vdproj parser wanted


I'm looking for some c# sample code or a tool that could parse .vdproj file (Visual 2010 Studio Setup and Deployment Project).


Solution

  • Suggest using C# and LINQ to parse this file. Let's go with this vdproj sample. Unfortunately it's not XML based, but rather it looks similar to JSON, but not exactly.

    alt text

    Suggest to iterate through the lines. Determine where you are based on the number of tabs seen, and the line number of the section heading you want to parse out.

      string[] allLines = System.IO.File.ReadAllLines(@"C:\foo.vdproj");
    
      // iterate, and determine where the Configuration heading is....
      if (line == "\t\"Configurations\"")
    

    My sample code is too large to paste here, so please see the code at http://pastebin.com/DAiTCUtD

    The complexity goes as far as how much data you need to extract from the file.

    Hope this helps. Sounds like you were looking for a prebuilt tool, but perhaps this code gets you started in parsing .vdproj files.