Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit c606467

Browse files
committed
Address PR feedback
1 parent 1d85c24 commit c606467

File tree

7 files changed

+27
-17
lines changed

7 files changed

+27
-17
lines changed

src/Microsoft.DotNet.ProjectJsonMigration/MigrationSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public MigrationSettings(
2323
ProjectDirectory = projectDirectory;
2424
OutputDirectory = outputDirectory;
2525
SdkPackageVersion = sdkPackageVersion;
26-
MSBuildProjectTemplate = msBuildProjectTemplate;
26+
MSBuildProjectTemplate = msBuildProjectTemplate != null ? msBuildProjectTemplate.DeepClone() : null;
2727
ProjectXProjFilePath = projectXprojFilePath;
2828
}
2929
}

src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependencyFinder.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace Microsoft.DotNet.ProjectJsonMigration
1717
{
18-
public class ProjectDependencyFinder
18+
internal class ProjectDependencyFinder
1919
{
2020
public IEnumerable<ProjectDependency> ResolveProjectDependencies(string projectDir, string xprojFile = null)
2121
{
@@ -71,10 +71,15 @@ public IEnumerable<ProjectDependency> ResolveProjectDependenciesForFramework(
7171
var dependencyName = projectFileDependency.Name;
7272

7373
ProjectDependency projectDependency;
74+
75+
if (preResolvedProjects.Contains(dependencyName))
76+
{
77+
continue;
78+
}
79+
7480
if (!possibleProjectDependencies.TryGetValue(dependencyName, out projectDependency))
7581
{
76-
if (projectFileDependency.LibraryRange.TypeConstraint == LibraryDependencyTarget.Project
77-
&& !preResolvedProjects.Contains(dependencyName))
82+
if (projectFileDependency.LibraryRange.TypeConstraint == LibraryDependencyTarget.Project)
7883
{
7984
MigrationErrorCodes
8085
.MIGRATE1014($"Unresolved project dependency ({dependencyName})").Throw();
@@ -269,7 +274,7 @@ private static List<ProjectDependency> GetPotentialProjects(IEnumerable<string>
269274
return projects;
270275
}
271276

272-
public static List<string> GetGlobalPaths(string rootPath)
277+
internal static List<string> GetGlobalPaths(string rootPath)
273278
{
274279
var paths = new List<string>();
275280

@@ -352,7 +357,8 @@ public static bool TryGetGlobalSettings(string path, out GlobalSettings globalSe
352357
var projects = settings["projects"];
353358
var dependencies = settings["dependencies"] as JObject;
354359

355-
globalSettings.ProjectPaths = projects == null ? new string[] { } : projects.Select(a => a.Value<string>()).ToArray(); ;
360+
globalSettings.ProjectPaths = projects == null ? new string[] { } :
361+
projects.Select(a => a.Value<string>()).ToArray();
356362
globalSettings.PackagesPath = settings.Value<string>("packages");
357363
globalSettings.FilePath = globalJsonPath;
358364
}

src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void Migrate(MigrationSettings rootSettings, bool skipProjectReferences =
6868
var settings = new MigrationSettings(projectDir,
6969
projectDir,
7070
rootSettings.SdkPackageVersion,
71-
tempMSBuildProjectTemplate.DeepClone());
71+
tempMSBuildProjectTemplate);
7272
MigrateProject(settings);
7373
}
7474
}

src/Microsoft.DotNet.ProjectJsonMigration/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
using System.Runtime.CompilerServices;
55

66
[assembly:InternalsVisibleTo("Microsoft.DotNet.ProjectJsonMigration.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100039ac461fa5c82c7dd2557400c4fd4e9dcdf7ac47e3d572548c04cd4673e004916610f4ea5cbf86f2b1ca1cb824f2a7b3976afecfcf4eb72d9a899aa6786effa10c30399e6580ed848231fec48374e41b3acf8811931343fc2f73acf72dae745adbcb7063cc4b50550618383202875223fc75401351cd89c44bf9b50e7fa3796")]
7+
[assembly: InternalsVisibleTo("dotnet, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

src/dotnet/commands/dotnet-migrate/MigrateCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public int Execute()
4747
Console.WriteLine($"Migrating project {project}..");
4848
var projectDirectory = Path.GetDirectoryName(project);
4949
var outputDirectory = projectDirectory;
50-
var migrationSettings = new MigrationSettings(projectDirectory, outputDirectory, sdkVersion, msBuildTemplate.DeepClone(), _xprojFilePath);
50+
var migrationSettings = new MigrationSettings(projectDirectory, outputDirectory, sdkVersion, msBuildTemplate, _xprojFilePath);
5151
new ProjectMigrator().Migrate(migrationSettings, _skipProjectReferences);
5252
}
5353

src/dotnet/commands/dotnet-migrate/Program.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ public static int Run(string[] args)
2727
app.HelpOption("-h|--help");
2828

2929
CommandArgument projectArgument = app.Argument("<PROJECT_JSON/GLOBAL_JSON/PROJECT_DIR>",
30-
"The path to " + Environment.NewLine +
31-
" - a project.json file to migrate." + Environment.NewLine +
32-
"or" + Environment.NewLine +
33-
" - a global.json file, it will migrate the folders specified in global.json." + Environment.NewLine +
34-
"or" + Environment.NewLine +
35-
" - a directory to migrate, it will recursively search for project.json files to migrate." + Environment.NewLine +
36-
"Defaults to current directory if nothing is specified.");
30+
string.Join(Environment.NewLine,
31+
"The path to ",
32+
" - a project.json file to migrate.",
33+
"or",
34+
" - a global.json file, it will migrate the folders specified in global.json.",
35+
"or",
36+
" - a directory to migrate, it will recursively search for project.json files to migrate.",
37+
"Defaults to current directory if nothing is specified."));
3738

3839
CommandOption template = app.Option("-t|--template-file", "Base MSBuild template to use for migrated app. The default is the project included in dotnet new -t msbuild", CommandOptionType.SingleValue);
3940
CommandOption sdkVersion = app.Option("-v|--sdk-package-version", "The version of the sdk package that will be referenced in the migrated app. The default is the version of the sdk in dotnet new -t msbuild", CommandOptionType.SingleValue);

test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,10 @@ public void It_migrates_and_builds_projects_in_global_json(string path, string p
271271

272272
private void VerifyMigration(IEnumerable<string> expectedProjects, string rootDir)
273273
{
274-
var migratedProjects = Directory.EnumerateFiles(rootDir, "project.migrated.json", SearchOption.AllDirectories)
275-
.Select(s => Path.GetFileName(Path.GetDirectoryName(s)));
274+
var migratedProjects = Directory.EnumerateFiles(rootDir, "project.json", SearchOption.AllDirectories)
275+
.Where(s => Directory.EnumerateFiles(Path.GetDirectoryName(s), "*.csproj").Count() == 1)
276+
.Where(s => Path.GetFileName(Path.GetDirectoryName(s)).Contains("Project"))
277+
.Select(s => Path.GetFileName(Path.GetDirectoryName(s)));
276278
migratedProjects.Should().BeEquivalentTo(expectedProjects);
277279
}
278280

0 commit comments

Comments
 (0)