Address PR feedback

This commit is contained in:
Sridhar Periyasamy 2016-10-05 16:25:04 -07:00
parent 1d85c241b1
commit c6064677db
7 changed files with 27 additions and 17 deletions

View file

@ -23,7 +23,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration
ProjectDirectory = projectDirectory; ProjectDirectory = projectDirectory;
OutputDirectory = outputDirectory; OutputDirectory = outputDirectory;
SdkPackageVersion = sdkPackageVersion; SdkPackageVersion = sdkPackageVersion;
MSBuildProjectTemplate = msBuildProjectTemplate; MSBuildProjectTemplate = msBuildProjectTemplate != null ? msBuildProjectTemplate.DeepClone() : null;
ProjectXProjFilePath = projectXprojFilePath; ProjectXProjFilePath = projectXprojFilePath;
} }
} }

View file

@ -15,7 +15,7 @@ using NuGet.LibraryModel;
namespace Microsoft.DotNet.ProjectJsonMigration namespace Microsoft.DotNet.ProjectJsonMigration
{ {
public class ProjectDependencyFinder internal class ProjectDependencyFinder
{ {
public IEnumerable<ProjectDependency> ResolveProjectDependencies(string projectDir, string xprojFile = null) public IEnumerable<ProjectDependency> ResolveProjectDependencies(string projectDir, string xprojFile = null)
{ {
@ -71,10 +71,15 @@ namespace Microsoft.DotNet.ProjectJsonMigration
var dependencyName = projectFileDependency.Name; var dependencyName = projectFileDependency.Name;
ProjectDependency projectDependency; ProjectDependency projectDependency;
if (preResolvedProjects.Contains(dependencyName))
{
continue;
}
if (!possibleProjectDependencies.TryGetValue(dependencyName, out projectDependency)) if (!possibleProjectDependencies.TryGetValue(dependencyName, out projectDependency))
{ {
if (projectFileDependency.LibraryRange.TypeConstraint == LibraryDependencyTarget.Project if (projectFileDependency.LibraryRange.TypeConstraint == LibraryDependencyTarget.Project)
&& !preResolvedProjects.Contains(dependencyName))
{ {
MigrationErrorCodes MigrationErrorCodes
.MIGRATE1014($"Unresolved project dependency ({dependencyName})").Throw(); .MIGRATE1014($"Unresolved project dependency ({dependencyName})").Throw();
@ -269,7 +274,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration
return projects; return projects;
} }
public static List<string> GetGlobalPaths(string rootPath) internal static List<string> GetGlobalPaths(string rootPath)
{ {
var paths = new List<string>(); var paths = new List<string>();
@ -352,7 +357,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration
var projects = settings["projects"]; var projects = settings["projects"];
var dependencies = settings["dependencies"] as JObject; var dependencies = settings["dependencies"] as JObject;
globalSettings.ProjectPaths = projects == null ? new string[] { } : projects.Select(a => a.Value<string>()).ToArray(); ; globalSettings.ProjectPaths = projects == null ? new string[] { } :
projects.Select(a => a.Value<string>()).ToArray();
globalSettings.PackagesPath = settings.Value<string>("packages"); globalSettings.PackagesPath = settings.Value<string>("packages");
globalSettings.FilePath = globalJsonPath; globalSettings.FilePath = globalJsonPath;
} }

View file

@ -68,7 +68,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration
var settings = new MigrationSettings(projectDir, var settings = new MigrationSettings(projectDir,
projectDir, projectDir,
rootSettings.SdkPackageVersion, rootSettings.SdkPackageVersion,
tempMSBuildProjectTemplate.DeepClone()); tempMSBuildProjectTemplate);
MigrateProject(settings); MigrateProject(settings);
} }
} }

View file

@ -4,3 +4,4 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
[assembly:InternalsVisibleTo("Microsoft.DotNet.ProjectJsonMigration.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100039ac461fa5c82c7dd2557400c4fd4e9dcdf7ac47e3d572548c04cd4673e004916610f4ea5cbf86f2b1ca1cb824f2a7b3976afecfcf4eb72d9a899aa6786effa10c30399e6580ed848231fec48374e41b3acf8811931343fc2f73acf72dae745adbcb7063cc4b50550618383202875223fc75401351cd89c44bf9b50e7fa3796")] [assembly:InternalsVisibleTo("Microsoft.DotNet.ProjectJsonMigration.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100039ac461fa5c82c7dd2557400c4fd4e9dcdf7ac47e3d572548c04cd4673e004916610f4ea5cbf86f2b1ca1cb824f2a7b3976afecfcf4eb72d9a899aa6786effa10c30399e6580ed848231fec48374e41b3acf8811931343fc2f73acf72dae745adbcb7063cc4b50550618383202875223fc75401351cd89c44bf9b50e7fa3796")]
[assembly: InternalsVisibleTo("dotnet, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

View file

@ -47,7 +47,7 @@ namespace Microsoft.DotNet.Tools.Migrate
Console.WriteLine($"Migrating project {project}.."); Console.WriteLine($"Migrating project {project}..");
var projectDirectory = Path.GetDirectoryName(project); var projectDirectory = Path.GetDirectoryName(project);
var outputDirectory = projectDirectory; var outputDirectory = projectDirectory;
var migrationSettings = new MigrationSettings(projectDirectory, outputDirectory, sdkVersion, msBuildTemplate.DeepClone(), _xprojFilePath); var migrationSettings = new MigrationSettings(projectDirectory, outputDirectory, sdkVersion, msBuildTemplate, _xprojFilePath);
new ProjectMigrator().Migrate(migrationSettings, _skipProjectReferences); new ProjectMigrator().Migrate(migrationSettings, _skipProjectReferences);
} }

View file

@ -27,13 +27,14 @@ namespace Microsoft.DotNet.Tools.Migrate
app.HelpOption("-h|--help"); app.HelpOption("-h|--help");
CommandArgument projectArgument = app.Argument("<PROJECT_JSON/GLOBAL_JSON/PROJECT_DIR>", CommandArgument projectArgument = app.Argument("<PROJECT_JSON/GLOBAL_JSON/PROJECT_DIR>",
"The path to " + Environment.NewLine + string.Join(Environment.NewLine,
" - a project.json file to migrate." + Environment.NewLine + "The path to ",
"or" + Environment.NewLine + " - a project.json file to migrate.",
" - a global.json file, it will migrate the folders specified in global.json." + Environment.NewLine + "or",
"or" + Environment.NewLine + " - a global.json file, it will migrate the folders specified in global.json.",
" - a directory to migrate, it will recursively search for project.json files to migrate." + Environment.NewLine + "or",
"Defaults to current directory if nothing is specified."); " - a directory to migrate, it will recursively search for project.json files to migrate.",
"Defaults to current directory if nothing is specified."));
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); 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);
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); 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);

View file

@ -271,7 +271,9 @@ namespace Microsoft.DotNet.Migration.Tests
private void VerifyMigration(IEnumerable<string> expectedProjects, string rootDir) private void VerifyMigration(IEnumerable<string> expectedProjects, string rootDir)
{ {
var migratedProjects = Directory.EnumerateFiles(rootDir, "project.migrated.json", SearchOption.AllDirectories) var migratedProjects = Directory.EnumerateFiles(rootDir, "project.json", SearchOption.AllDirectories)
.Where(s => Directory.EnumerateFiles(Path.GetDirectoryName(s), "*.csproj").Count() == 1)
.Where(s => Path.GetFileName(Path.GetDirectoryName(s)).Contains("Project"))
.Select(s => Path.GetFileName(Path.GetDirectoryName(s))); .Select(s => Path.GetFileName(Path.GetDirectoryName(s)));
migratedProjects.Should().BeEquivalentTo(expectedProjects); migratedProjects.Should().BeEquivalentTo(expectedProjects);
} }