提交 e6ba851f 编写于 作者: B Balaji Soundrarajan 提交者: GitHub

Merge pull request #20867 from basoundr/IntgTestAPIChange

Update Integration tests utility to support Unload/Reload project and nuget restore
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.IO;
namespace Microsoft.VisualStudio.IntegrationTest.Utilities.Common.ProjectUtils
{
public abstract class Identity
......@@ -9,10 +11,24 @@ public abstract class Identity
public class Project : Identity
{
public Project(string name)
public Project(string name, string projectExtension = ".csproj", string relativePath = null)
{
Name = name;
if (string.IsNullOrWhiteSpace(relativePath))
{
RelativePath = Path.Combine(name, name + projectExtension);
}
else
{
RelativePath = relativePath;
}
}
/// <summary>
/// This path is relative to the Solution file. Default value is set to ProjectName\ProjectName.csproj
/// </summary>
public string RelativePath { get; }
}
public class ProjectReference : Identity
......
......@@ -808,10 +808,10 @@ private string GetAbsolutePathForProjectRelativeFilePath(string projectName, str
return Path.Combine(projectPath, relativeFilePath);
}
public void ReloadProject(string projectName)
public void ReloadProject(string projectRelativePath)
{
var solutionPath = Path.GetDirectoryName(_solution.FullName);
var projectPath = Path.Combine(solutionPath, projectName);
var projectPath = Path.Combine(solutionPath, projectRelativePath);
_solution.AddFromFile(projectPath);
}
......@@ -829,7 +829,17 @@ public void ShowOutputWindow()
public void UnloadProject(string projectName)
{
var project = _solution.Projects.Item(projectName);
var projects = _solution.Projects;
EnvDTE.Project project = null;
for (int i = 1; i <= projects.Count; i++)
{
project = projects.Item(i);
if (string.Compare(project.Name, projectName, StringComparison.Ordinal) == 0)
{
break;
}
}
_solution.Remove(project);
}
......
......@@ -117,7 +117,7 @@ public void SaveFile(ProjectUtils.Project project, string fileName)
=> _inProc.SaveFile(project.Name, fileName);
public void ReloadProject(ProjectUtils.Project project)
=> _inProc.ReloadProject(project.Name);
=> _inProc.ReloadProject(project.RelativePath);
public void RestoreNuGetPackages()
=> _inProc.RestoreNuGetPackages();
......
......@@ -33,7 +33,7 @@ public static class WellKnownCommandNames
public const string InteractiveConsole_ClearScreen = "InteractiveConsole.ClearScreen";
public const string InteractiveConsole_ExecuteInInteractive = "InteractiveConsole.ExecuteInInteractive";
public const string ProjectAndSolutionContextMenus_Solution_RestoreNuGetPackages = "ProjectAndSolutionContextMenus.Solution.RestoreNuGetPackages";
public const string ProjectAndSolutionContextMenus_Solution_RestoreNuGetPackages = "ProjectandSolutionContextMenus.Solution.RestoreNuGetPackages";
public const string ProjectAndSolutionContextMenus_Project_ResetCSharpInteractiveFromProject
= "ProjectandSolutionContextMenus.Project.ResetC#InteractiveFromProject";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册