private void AddSkinnedModelAndPipeLineProject() { if (currentProject == null) { return; } Solution2 solution = (Solution2)applicationObject.Solution; string dirPath = Path.GetDirectoryName(solution.FullName) + "\\SkinnedModel"; FileHelper.DirectoryCopy(AssemblyDirectory + "\\templates\\SkinnedModel", dirPath, true); skinnedModelProject = solution.AddFromFile(dirPath + "\\SkinnedModel.csproj"); VSLangProj.VSProject project; project = (VSLangProj.VSProject)currentProject.Object; project.References.AddProject(skinnedModelProject); dirPath = Path.GetDirectoryName(solution.FullName) + "\\SkinnedModelPipeline"; FileHelper.DirectoryCopy(AssemblyDirectory + "\\templates\\SkinnedModelPipeline", dirPath, true); skinnedModelPipelineProject = solution.AddFromFile(dirPath + "\\SkinnedModelPipeline.csproj"); project = (VSLangProj.VSProject)skinnedModelPipelineProject.Object; project.References.AddProject(skinnedModelProject); project = (VSLangProj.VSProject)contentProject.Object; project.References.AddProject(skinnedModelPipelineProject); }
public void AddCustomProject(string projectName, string projectFileExtension, string projectFileContent) { var projectPath = Path.Combine(DirectoryName, projectName); Directory.CreateDirectory(projectPath); var projectFilePath = Path.Combine(projectPath, projectName + projectFileExtension); File.WriteAllText(projectFilePath, projectFileContent); _solution.AddFromFile(projectFilePath); }
public void ReloadProject(string projectName) { var solutionPath = Path.GetDirectoryName(_solution.FullName); var projectPath = Path.Combine(solutionPath, projectName); _solution.AddFromFile(projectPath); }
private Project MoveProjectTo(string targetSubFolder, EnvDTE.Project project, string solutionFolderName) { string projectName = project.Name; string originalLocation = GetSolutionRootPath() + GetSolutionName() + "\\" + projectName; if (Directory.Exists(originalLocation)) { Solution2 solution = dte.Solution as Solution2; Log("MoveProjectTo: Removing " + projectName + " from solution"); solution.Remove(project); // Give the solution time to release the lock on the project file System.Threading.Thread.Sleep(MIN_TIME_FOR_PROJECT_TO_RELEASE_FILE_LOCK); PerformManualProjectReplacementsTo(originalLocation + "\\" + projectName + ".csproj"); string targetLocation = GetSolutionRootPath() + GetSolutionName() + targetSubFolder + projectName; Log("MoveProjectTo: Moving " + projectName + " from " + originalLocation + " to target location at " + targetLocation); Directory.Move(originalLocation, targetLocation); if (!string.IsNullOrEmpty(solutionFolderName)) { SolutionFolder solutionFolder = (SolutionFolder)solution.AddSolutionFolder(solutionFolderName).Object; Log("MoveProjectTo: Adding " + projectName + " to solution folder " + targetLocation); return(solutionFolder.AddFromFile(targetLocation + "\\" + projectName + ".csproj")); } else { Log("MoveProjectTo: Adding " + projectName + " to solution"); return(solution.AddFromFile(targetLocation + "\\" + projectName + ".csproj", false)); } } else { throw new ApplicationException("Couldn't find " + originalLocation + " to move"); } }
private Project MoveProjectTo(string targetSubFolder, EnvDTE.Project project, string solutionFolderName) { string projectName = project.Name; string originalLocation = GetSolutionRootPath() + GetSolutionName() + "\\" + projectName; if (Directory.Exists(originalLocation)) { Solution2 solution = dte.Solution as Solution2; solution.Remove(project); // Give the solution time to release the lock on the project file System.Threading.Thread.Sleep(MIN_TIME_FOR_PROJECT_TO_RELEASE_FILE_LOCK); string targetLocation = GetSolutionRootPath() + GetSolutionName(); moveFolderContentsToFolder(originalLocation, targetLocation, true); return(solution.AddFromFile(targetLocation + "\\" + _solutionName + ".csproj", false)); } else { throw new ApplicationException("Couldn't find " + originalLocation + " to move"); } }
public Project AddProjectFromFileTo(Solution2 solution, string path) { if (!File.Exists(path) && solution == null) return null; Logger.WriteLine("Adding project from " + path + " to solution"); return solution.AddFromFile(path, false); }
private void AddJitterProject() { if (currentProject == null) { return; } Solution2 solution = (Solution2)applicationObject.Solution; string dirPath = Path.GetDirectoryName(solution.FullName) + "\\Jitter"; FileHelper.DirectoryCopy(AssemblyDirectory + "\\templates\\Jitter", dirPath, true); jitterProject = solution.AddFromFile(dirPath + "\\Jitter.csproj"); VSLangProj.VSProject project; project = (VSLangProj.VSProject)currentProject.Object; project.References.AddProject(jitterProject); }
public INVsProject AddExistingProject(string projectFilePath) { var project = Solution.AddFromFile(projectFilePath); return(new NVsProject(Solution, project)); }
public ShellProject AddFromFile(string FileName, bool Exclusive) { return(new ShellProject(_solution.AddFromFile(FileName, Exclusive))); }
public IPathNode NewItem(IContext context, string path, string itemTypeName, object newItemValue) { var p = context.DynamicParameters as NewItemDynamicParameters ?? new NewItemDynamicParameters(); Solution2 sln = _dte.Solution as Solution2; Project item = null; Events2 events2 = _dte.Events as Events2; var callback = (_dispSolutionEvents_ProjectAddedEventHandler)((a) => item = a); events2.SolutionEvents.ProjectAdded += callback; try { if (!String.IsNullOrEmpty(itemTypeName)) { if ("folder" == itemTypeName.ToLowerInvariant()) { sln.AddSolutionFolder(path); } else { if (!itemTypeName.ToLowerInvariant().EndsWith(".zip")) { itemTypeName += ".zip"; } if (String.IsNullOrEmpty(p.Language)) { p.Language = "csharp"; } var projectName = Path.GetFileNameWithoutExtension(path); var destinationPath = Path.Combine( Path.GetDirectoryName(sln.FullName), projectName ); var projectFileName = path; /*if (String.IsNullOrEmpty(Path.GetExtension(path))) * { * projectFileName += GetProjectFileExtension(p.Language); * }*/ var t = sln.GetProjectTemplate(itemTypeName, p.Language); _dte.Solution.AddFromTemplate(t, destinationPath, projectFileName, false); } } else if (!String.IsNullOrEmpty(p.ItemFilePath)) { sln.AddFromFile(p.ItemFilePath, false); } } finally { events2.SolutionEvents.ProjectAdded -= callback; } if (null == item) { return(null); } var factory = new ProjectNodeFactory(item); return(factory.GetNodeValue()); }