Changing the order in which search paths are added for migration and setting the project file path in the ProjectDependency appropriately in the case of csproj and project.json
This commit is contained in:
parent
64042937cf
commit
6a72ec603e
5 changed files with 30 additions and 4 deletions
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"projects": [ "src", "test" ]
|
||||
"projects": [ "src" ]
|
||||
}
|
|
@ -230,10 +230,10 @@ namespace Microsoft.DotNet.ProjectJsonMigration
|
|||
projectSearchPaths.Add(projectRootDirectory);
|
||||
|
||||
var globalPaths = GetGlobalPaths(projectRootDirectory);
|
||||
projectSearchPaths = projectSearchPaths.Union(globalPaths).ToList();
|
||||
projectSearchPaths = globalPaths.Union(projectSearchPaths).ToList();
|
||||
|
||||
var solutionPaths = GetSolutionPaths(slnFile);
|
||||
projectSearchPaths = projectSearchPaths.Union(solutionPaths).ToList();
|
||||
projectSearchPaths = solutionPaths.Union(projectSearchPaths).ToList();
|
||||
|
||||
var projects = new Dictionary<string, ProjectDependency>(StringComparer.Ordinal);
|
||||
|
||||
|
@ -328,11 +328,16 @@ namespace Microsoft.DotNet.ProjectJsonMigration
|
|||
var projectJSONFilePath = Path.Combine(projectDirectory.FullName, "project.json");
|
||||
var csProjFilePath = Path.Combine(projectDirectory.FullName, $"{projectDirectory.Name}.csproj");
|
||||
|
||||
if (File.Exists(projectJSONFilePath) || File.Exists(csProjFilePath))
|
||||
if (File.Exists(projectJSONFilePath))
|
||||
{
|
||||
var project = new ProjectDependency(projectDirectory.Name, projectJSONFilePath);
|
||||
projects.Add(project);
|
||||
}
|
||||
else if (File.Exists(csProjFilePath))
|
||||
{
|
||||
var project = new ProjectDependency(projectDirectory.Name, csProjFilePath);
|
||||
projects.Add(project);
|
||||
}
|
||||
}
|
||||
|
||||
internal static List<string> GetGlobalPaths(string rootPath)
|
||||
|
|
|
@ -302,6 +302,27 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
item => item.ItemType == "ProjectReference" && item.Include == projectReferenceInclude);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItDoesNotReferenceTheProjectUnderBackupWhenMigratingAPartiallyMigratedStructure()
|
||||
{
|
||||
var testAssetsManager = GetTestGroupTestAssetsManager("NonRestoredTestProjects");
|
||||
var solutionDirectory = testAssetsManager.CreateTestInstance("PJHalfMigrated").Path;
|
||||
|
||||
var appDirectory = Path.Combine(solutionDirectory, "ProjectB");
|
||||
|
||||
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
|
||||
var mockProj = ProjectRootElement.Create();
|
||||
var testSettings = MigrationSettings.CreateMigrationSettingsTestHook(appDirectory, appDirectory, mockProj, null);
|
||||
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(),
|
||||
mockProj.AddPropertyGroup());
|
||||
new MigrateProjectDependenciesRule().Apply(testSettings, testInputs);
|
||||
|
||||
var projectReferences = mockProj.Items.Where(
|
||||
item => item.ItemType.Equals("ProjectReference", StringComparison.Ordinal));
|
||||
projectReferences.Should().ContainSingle();
|
||||
projectReferences.Single().Include.Should().Be("../src/ProjectA/ProjectA.csproj");
|
||||
}
|
||||
|
||||
private ProjectRootElement MigrateProject(string solution, string project)
|
||||
{
|
||||
return MigrateProject(solution, project, FrameworkConstants.CommonFrameworks.NetCoreApp10);
|
||||
|
|
Loading…
Reference in a new issue