Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8946681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:34:46+00:00 2026-06-15T12:34:46+00:00

We needed to automate testing that all of the C#, C++, & VB.NET samples

  • 0

We needed to automate testing that all of the C#, C++, & VB.NET samples we ship compile properly. We need it to build all files without our listing each one. Listing each one means if someone forgets to add a new one (which will happen someday), explicit calls will miss it. By walking all .sln files, we always get everything.

Doing this is pretty easy:

  1. Install the samples on a clean VM (that we revert back to the snapshot for each test run).
  2. Create a BuildAll.proj (MSBuild) file that calls all the .sln files installed.
  3. Use MSBuild to run the generated BuildAll.proj file

Step 2 requires a means to generate the BuildAll.proj file. Is there any way to tell MSBuild to run all .sln files under a sub-directory or to create a BuildAll.proj that calls all the underlying .slnl files?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:34:47+00:00Added an answer on June 15, 2026 at 12:34 pm

    We couldn’t find anything so we wrote a program that creates a BuildAll.proj that calls all .sln files under a directory. Full solution is at Windward Wrocks (my blog).

    The code is:

    using System; 
    using System.IO; 
    using System.Text; 
    using System.Xml; 
    using System.Xml.Linq; 
    
    
    namespace BuildDotNetTestScript 
    { 
        /// <summary> 
        /// Builds a test script to compile all .sln files under the directory in. 
        /// </summary> 
        public class Program 
        { 
            private static readonly XNamespace xmlns = "http://schemas.microsoft.com/developer/msbuild/2003"; 
    
    
            private enum VS_VER 
            { 
                VS_2005, 
                VS_2008, 
                VS_2010, 
                NONE 
            } 
    
    
            private static VS_VER vsVersion = VS_VER.NONE; 
    
    
            /// <summary> 
            /// Build TestAll.proj for all .sln files in this directory and sub-directories. 
            /// </summary> 
            /// <param name="args">Optional: [-VS2005 | -VS2008 | -VS2010] TestAll.proj root_folder</param> 
            public static void Main(string[] args) 
            { 
    
    
                int indexArgs = 0; 
                if (args.Length >= 1 && args[0][0] == '-') 
                { 
                    indexArgs = 1; 
                    switch (args[0].ToUpper().Trim()) 
                    { 
                        case "-VS2005": 
                            vsVersion = VS_VER.VS_2005; 
                            break; 
                        case "-VS2008": 
                            vsVersion = VS_VER.VS_2008; 
                            break; 
                        case "-VS2010": 
                            vsVersion = VS_VER.VS_2010; 
                            break; 
                        default: 
                            Console.Error.WriteLine("Only options are -VS2005, -VS2008, or -VS2010"); 
                            Environment.Exit(1); 
                            return; 
                    } 
                } 
    
    
                string projFile = Path.GetFullPath(args.Length > indexArgs ? args[indexArgs] : "TestAll.proj"); 
                string rootDirectory = 
                    Path.GetFullPath(args.Length > indexArgs + 1 ? args[indexArgs + 1] : Directory.GetCurrentDirectory()); 
                Console.Out.WriteLine(string.Format("Creating project file {0}", projFile)); 
                Console.Out.WriteLine(string.Format("Root directory {0}", rootDirectory)); 
    
    
                XDocument xdoc = new XDocument(); 
                XElement elementProject = new XElement(xmlns + "Project"); 
                xdoc.Add(elementProject); 
                elementProject.Add(new XAttribute("DefaultTargets", "compile")); 
                elementProject.Add(new XAttribute("ToolsVersion", "3.5")); 
    
    
                XElement elementPropertyGroup = new XElement(xmlns + "PropertyGroup"); 
                elementProject.Add(elementPropertyGroup); 
                XElement elementDevEnv = new XElement(xmlns + "devenv"); 
                elementPropertyGroup.Add(elementDevEnv); 
                elementDevEnv.Value = "devenv.exe"; 
    
    
                XElement elementTarget = new XElement(xmlns + "Target"); 
                elementProject.Add(elementTarget); 
                elementTarget.Add(new XAttribute("Name", "compile")); 
    
    
                // add .sln files - recursively 
                AddSlnFiles(elementTarget, rootDirectory, rootDirectory); 
    
    
                Console.Out.WriteLine("writing project file to disk"); 
                // no BOM 
                using (var writer = new XmlTextWriter(projFile, new UTF8Encoding(false))) 
                { 
                    writer.Formatting = Formatting.Indented; 
                    xdoc.Save(writer); 
                } 
    
    
                Console.Out.WriteLine("all done"); 
            } 
    
    
            private static void AddSlnFiles(XElement elementTarget, string rootDirectory, string folder) 
            { 
    
    
                // add .sln files 
                foreach (string fileOn in Directory.GetFiles(folder, "*.sln")) 
                { 
                    // .../JS/... is VS2005 
                    bool isJSharp = fileOn.ToUpper().Replace('\\', '/').Contains("/JS/"); 
                    bool versionMatch = true; 
                    switch (vsVersion) 
                    { 
                        case VS_VER.VS_2005: 
                            if ((!fileOn.ToUpper().Contains("VS2005")) && (! isJSharp)) 
                                versionMatch = false; 
                            break; 
                        case VS_VER.VS_2008: 
                            if (isJSharp || !fileOn.ToUpper().Contains("VS2008")) 
                                versionMatch = false; 
                            break; 
                        case VS_VER.VS_2010: 
                            if (isJSharp || !fileOn.ToUpper().Contains("VS2010")) 
                                versionMatch = false; 
                            break; 
                        default: 
                            if (isJSharp || fileOn.ToUpper().Contains("VS2005") || fileOn.ToUpper().Contains("VS2008") || fileOn.ToUpper().Contains("VS2010")) 
                                versionMatch = false; 
                            break; 
                    } 
                    if (!versionMatch) 
                        continue; 
    
    
                    string command = string.Format("\"$(devenv)\" \"{0}\" /Rebuild", Path.GetFileName(fileOn)); 
                    XElement elementExec = new XElement(xmlns + "Exec"); 
                    elementExec.Add(new XAttribute("Command", command)); 
    
    
                    string workingFolder; 
                    if (folder.StartsWith(rootDirectory)) 
                    { 
                        workingFolder = folder.Substring(rootDirectory.Length).Trim(); 
                        if ((workingFolder.Length > 0) && (workingFolder[0] == Path.DirectorySeparatorChar || workingFolder[0] == Path.AltDirectorySeparatorChar)) 
                            workingFolder = workingFolder.Substring(1); 
                    } 
                    else 
                        workingFolder = folder; 
                    if (workingFolder.Length > 0) 
                        elementExec.Add(new XAttribute("WorkingDirectory", workingFolder)); 
                    elementTarget.Add(elementExec); 
                } 
    
    
                // look in sub-directories 
                foreach (string subDirectory in Directory.GetDirectories(folder)) 
                    AddSlnFiles(elementTarget, rootDirectory, subDirectory); 
            } 
        } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I needed to build an Android app that lets you view a web page
I need to automate the UI testing of an iPhone application, i.e. if in
I use jquery all the time and couldn't build a great website without it.
In order to support automated testing tools I need to x:Name all controls (so
I need to automate a clean-up of a Linux based FTP server that only
i was looking for a way to automate all the casting needed to have
I´ve got one project, where all my .h and .cpp files are included. This
When writing a batch file to automate something on a Windows box, I've needed
I have a report that I need to export to a csv file for
I'm wondering if anyone knows about software that can automate custom builds for Ubuntu.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.