public void WhenANewCodedUITestProjectIsCreatedWithPlatform(string platform) { using (new TemporaryEnvironmentVariable("VisualStudioVersion", string.Format("{0}.0", this.visualStudioVersionNumber))) { Type type = Type.GetTypeFromProgID(this.visualStudioProgramId); Object obj = Activator.CreateInstance(type, true); this.dte = (DTE)obj; } this.dte.MainWindow.Visible = true; this.dte.UserControl = true; // create a new solution this.solutionDirectory = new TempDirectory(); // this.solutionDirectory.DeleteDirectoryOnDispose = false; this.dte.Solution.Create(this.solutionDirectory.DirectoryPath, "NewSolution"); this.visualStudio = new VisualStudioAutomation(this.dte); // this.visualStudio.QuitVisualStudioOnDispose = false; this.solution = this.dte.Solution; // create a test project this.testProjectPath = Path.Combine(this.solutionDirectory.DirectoryPath, ProjectName); using (TempDirectory projectTemplateDirectory = new TempDirectory()) { this.ConfigureTemplate(this.testProjectTemplatePath, "TestProject.vstemplate", projectTemplateDirectory.DirectoryPath); string testProjectTemplateFilePath = Path.Combine(projectTemplateDirectory.DirectoryPath, "TestProject.vstemplate"); Trace.WriteLine(string.Format("Creating test project '{0}' in '{1}' using template '{2}'...", ProjectName, this.testProjectPath, testProjectTemplateFilePath)); this.solution.AddFromTemplate(string.Format("{0}|$targetframeworkversion$={1}", testProjectTemplateFilePath, platform), this.testProjectPath, ProjectName); foreach (Project project in this.solution.Projects) { if (project.Name != ProjectName) { continue; } this.testProject = project; break; } Assert.IsNotNull(this.testProject); } using (TempDirectory templateDirectory = new TempDirectory()) { this.ConfigureTemplate(this.codedUiTestTemplatePath, "CodedUITest.vstemplate", templateDirectory.DirectoryPath, true); string templateFile = Path.Combine(templateDirectory.DirectoryPath, "CodedUITest.vstemplate"); string name = "CodedUITest.cs"; Trace.WriteLine(string.Format("Adding project item '{0}' from template '{1}'...", name, templateFile)); this.testProject.ProjectItems.AddFromTemplate(templateFile, name); } VSProject vsProject = this.testProject.Object as VSProject; if (vsProject == null) { throw new Exception("Failed to convert Project to VSProject."); } foreach (Reference projectReference in vsProject.References) { if (new[] { "Microsoft.VisualStudio.QualityTools.CodedUITestFramework", "Microsoft.VisualStudio.TestTools.UITest.Common", "Microsoft.VisualStudio.TestTools.UITest.Extension", "Microsoft.VisualStudio.TestTools.UITest.Extension.Firefox", "Microsoft.VisualStudio.TestTools.UITesting" }.Contains(projectReference.Name)) { projectReference.CopyLocal = false; } } }