PtiTom

Create SLN Programatically.

Jun 23rd, 2014
223
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Add Ref to EnvDTE80.dll
  2. // Warning : Close All VS instance before running :)
  3.  
  4. public string BuildSolution()
  5. {
  6.     StringBuilder status = new StringBuilder("Projets non traités :");
  7.     status.AppendLine();
  8.     try
  9.     {
  10.         EnvDTE80.DTE2 dte2;
  11.         dte2 = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.11.0");
  12.         dte2.Solution.Create(@"D:\Temp\", "AllSLProjects");
  13.         foreach (string projectFile in this.allProj)
  14.         {
  15.             try
  16.             {
  17.                 dte2.Solution.AddFromFile(projectFile, false);
  18.             }
  19.             catch (Exception ex )
  20.             {
  21.                 status.AppendFormat("{0} : {1}{2}", projectFile, ex, Environment.NewLine);
  22.             }
  23.         }
  24.  
  25.         dte2.Solution.SaveAs("AllSLProjects.sln");
  26.         dte2.Quit();
  27.     }
  28.     catch (Exception e)
  29.     {
  30.         Debug.WriteLine(e.ToString());
  31.     }
  32.  
  33.     return status.ToString();
  34. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×