@@ -107,4 +107,72 @@ $xml.Save($testAppProject)
107
107
FindAndReplaceInFile ($muxControlsDir + " \dev\Telemetry\RuntimeProfiler.h" ) " (\s*ProfId_Size.*\s*})" @"
108
108
109
109
ProfId_$controlName ,`$ 1
110
- "@
110
+ "@
111
+ # Randomize class name for multiple use of class in one powershell
112
+ $id = get-random
113
+
114
+ # We need double backslash for C# strings below
115
+ $cleanMuxControlsDir = $muxControlsDir.Replace (" \" , " \\" ) + " \\"
116
+
117
+ echo " $cleanMuxControlsDir "
118
+
119
+ $assemblies = (
120
+ " System" , " EnvDTE" , " EnvDTE80"
121
+ )
122
+
123
+ $source = @"
124
+ using System;
125
+ using EnvDTE;
126
+ using EnvDTE80;
127
+ using System.Collections.Generic;
128
+ namespace SolutionHelper
129
+ {
130
+ public static class SolutionRegister$id {
131
+ public static void Main(){
132
+ Console.WriteLine("Started script");
133
+ var dteType = Type.GetTypeFromProgID("VisualStudio.DTE.16.0", true);
134
+ if(dteType == null)
135
+ {
136
+ Console.WriteLine("You need to install Visual Studio to add projects to the solution");
137
+ return;
138
+ }
139
+ var dte = (EnvDTE.DTE)System.Activator.CreateInstance(dteType);
140
+ var sln = (SolutionClass)dte.Solution;
141
+ Solution2 solution = (Solution2)dte.Solution;
142
+ Console.WriteLine("Got solution class");
143
+
144
+ var solutionNames = new List<string>(){"MUXControls.sln","MUXControlsInnerLoop.sln"};
145
+ foreach(var solutionName in solutionNames)
146
+ {
147
+ Console.WriteLine("Opening solution: $ ( $cleanMuxControlsDir ) " + solutionName);
148
+ solution.Open("$cleanMuxControlsDir " + solutionName);
149
+ Console.WriteLine("Opened solution");
150
+ var devFolder = solution.Projects.Item(1);
151
+
152
+ // Get correct reference here:
153
+ Console.WriteLine("Get dev folder");
154
+ var devSolutionFolder = (SolutionFolder)devFolder.Object;
155
+ Console.WriteLine("Add folder");
156
+ SolutionFolder newControlFolder = (SolutionFolder)devSolutionFolder.AddSolutionFolder("$controlName ").Object;
157
+
158
+ Console.WriteLine("Adding projects:");
159
+ Console.WriteLine("Adding source");
160
+ newControlFolder.AddFromFile("$ ( $cleanMuxControlsDir ) dev\\$ ( $controlName ) \\$ ( $controlName ) .vcxitems");
161
+ Console.WriteLine("Adding test UI");
162
+ newControlFolder.AddFromFile("$ ( $cleanMuxControlsDir ) dev\\$ ( $controlName ) /TestUI/$ ( $controlName ) _TestUI.shproj");
163
+ Console.WriteLine("Adding interactions test");
164
+ newControlFolder.AddFromFile("$ ( $cleanMuxControlsDir ) dev\\$ ( $controlName ) \\InteractionTests\\$ ( $controlName ) _InteractionTests.shproj");
165
+ Console.WriteLine("Finished adding projects, saving solution");
166
+
167
+ solution.Close(true);
168
+ Console.WriteLine("Saved solution" + solutionName);
169
+ }
170
+ }
171
+ }
172
+ }
173
+ "@
174
+
175
+
176
+ Add-Type - ReferencedAssemblies $assemblies - TypeDefinition $source - Language CSharp
177
+
178
+ iex " [SolutionHelper.SolutionRegister$id ]::Main()"
0 commit comments