Advertisement
PtiTom

Create SLN Programatically.

Jun 23rd, 2014
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement