From 5ede3b6367314020b414818297dd79d9d18e47cd Mon Sep 17 00:00:00 2001 From: Piotr Puszkiewicz Date: Sat, 29 Oct 2016 01:58:37 -0700 Subject: [PATCH] post migration cleanup (#4449) * Create tests * Basic scenario working & tested * Feature Complete * prevent build of intentionally broken test asset * Update migrate command backup * PR Feedback * Move negative test to negative test directory * Fix tests * make test output directories unique * Merge Conflict * make backup the default behavior * Pass2Fail * Remove tests' PJ dependency --- .../TestApp/.noautobuild | 0 .../TestApp/Program.cs | 17 +++ .../TestApp/project.json | 30 +++++ .../TestLibrary/.noautobuild | 0 .../TestLibrary/Helper.cs | 24 ++++ .../TestLibrary/project.json | 22 ++++ .../global.json | 3 + .../commands/dotnet-migrate/MigrateCommand.cs | 86 ++++++++++++-- src/dotnet/commands/dotnet-migrate/Program.cs | 6 +- .../GivenThatIWantToMigrateAssemblyInfo.cs | 2 +- .../Assertions/DirectoryInfoAssertions.cs | 54 ++++++++- .../Commands/MigrateCommand.cs | 29 +++++ .../GivenThatAnAppWasMigrated.cs | 111 ++++++++++++++++++ .../GivenThatIWantToMigrateTestApps.cs | 11 +- 14 files changed, 376 insertions(+), 19 deletions(-) create mode 100644 TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestApp/.noautobuild create mode 100644 TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestApp/Program.cs create mode 100644 TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestApp/project.json create mode 100644 TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestLibrary/.noautobuild create mode 100644 TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestLibrary/Helper.cs create mode 100644 TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestLibrary/project.json create mode 100644 TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/global.json create mode 100644 test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/MigrateCommand.cs create mode 100644 test/dotnet-migrate.Tests/GivenThatAnAppWasMigrated.cs diff --git a/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestApp/.noautobuild b/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestApp/.noautobuild new file mode 100644 index 000000000..e69de29bb diff --git a/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestApp/Program.cs b/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestApp/Program.cs new file mode 100644 index 000000000..ac3163a58 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestApp/Program.cs @@ -0,0 +1,17 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Diagnostics; + +namespace TestApp +{ + public class Program + { + public static int Main(string[] args) + { + Console.WriteLine(TestLibrary.Helper.GetMessage()); + return 100; + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestApp/project.json b/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestApp/project.json new file mode 100644 index 000000000..666d644b9 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestApp/project.json @@ -0,0 +1,30 @@ +{ + "version": "1.0.0-*", + "buildOptions": { + "emitEntryPoint": true, + "preserveCompilationContext": true + }, + "dependencies": { + "TestLibrary": { + "target": "project", + "version": "1.0.0-*" + }, + "Microsoft.NETCore.App": "1.0.1" + }, + "frameworks": { + "netcoreapp1.0": {} + }, + "runtimes": { + "win7-x64": {}, + "win7-x86": {}, + "osx.10.10-x64": {}, + "osx.10.11-x64": {}, + "ubuntu.14.04-x64": {}, + "ubuntu.16.04-x64": {}, + "centos.7-x64": {}, + "rhel.7.2-x64": {}, + "debian.8-x64": {}, + "fedora.23-x64": {}, + "opensuse.13.2-x64": {} + } +} diff --git a/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestLibrary/.noautobuild b/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestLibrary/.noautobuild new file mode 100644 index 000000000..e69de29bb diff --git a/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestLibrary/Helper.cs b/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestLibrary/Helper.cs new file mode 100644 index 000000000..8c643796b --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestLibrary/Helper.cs @@ -0,0 +1,24 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; + +namespace TestLibrary +{ + public static class Helper + { + /// + /// Gets the message from the helper. This comment is here to help test XML documentation file generation, please do not remove it. + /// + /// A message + public static string GetMessage() + { + return "This string came from the test library!"; + } + + public static void SayHi() + { + Console.WriteLine("Hello there!"); + } + } +} diff --git a/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestLibrary/project.json b/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestLibrary/project.json new file mode 100644 index 000000000..2470e823b --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/TestLibrary/project.json @@ -0,0 +1,22 @@ +{ + "version": "1.0.0-*", + "buildOptions": { + "nowarn": [ + "CS1591" + ], + "xmlDoc": true, + "additionalArguments": [ + "-highentropyva+" + ] + }, + "dependencies": { + "MissingP2PDependency": { + "target": "project", + "version": "1.0.0-*" + }, + "NETStandard.Library": "1.6.0" + }, + "frameworks": { + "netstandard1.5": {} + } +} diff --git a/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/global.json b/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/global.json new file mode 100644 index 000000000..3a4684c26 --- /dev/null +++ b/TestAssets/NonRestoredTestProjects/TestAppWithLibraryAndMissingP2P/global.json @@ -0,0 +1,3 @@ +{ + "projects": [ "."] +} \ No newline at end of file diff --git a/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs b/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs index e83ee63a4..420dc1e1b 100644 --- a/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs +++ b/src/dotnet/commands/dotnet-migrate/MigrateCommand.cs @@ -11,12 +11,15 @@ using Microsoft.Build.Evaluation; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.ProjectJsonMigration; using Microsoft.DotNet.Internal.ProjectModel; -using ProjectModel = Microsoft.DotNet.Internal.ProjectModel.Project; +using Project = Microsoft.DotNet.Internal.ProjectModel.Project; +using Microsoft.DotNet.Tools.Common; namespace Microsoft.DotNet.Tools.Migrate { public partial class MigrateCommand { + private readonly DirectoryInfo _workspaceDirectory; + private readonly DirectoryInfo _backupDirectory; private readonly string _templateFile; private readonly string _projectArg; private readonly string _sdkVersion; @@ -24,6 +27,7 @@ namespace Microsoft.DotNet.Tools.Migrate private readonly bool _skipProjectReferences; private readonly string _reportFile; private readonly bool _reportFormatJson; + private readonly bool _skipBackup; public MigrateCommand( string templateFile, @@ -32,15 +36,21 @@ namespace Microsoft.DotNet.Tools.Migrate string xprojFilePath, string reportFile, bool skipProjectReferences, - bool reportFormatJson) - { + bool reportFormatJson, + bool skipBackup) + { _templateFile = templateFile; _projectArg = projectArg ?? Directory.GetCurrentDirectory(); + _workspaceDirectory = File.Exists(_projectArg) + ? new FileInfo(_projectArg).Directory + : new DirectoryInfo(_projectArg); + _backupDirectory = new DirectoryInfo(Path.Combine(_workspaceDirectory.FullName, "backup")); _sdkVersion = sdkVersion; _xprojFilePath = xprojFilePath; _skipProjectReferences = skipProjectReferences; _reportFile = reportFile; _reportFormatJson = reportFormatJson; + _skipBackup = skipBackup; } public int Execute() @@ -82,12 +92,73 @@ namespace Microsoft.DotNet.Tools.Migrate temporaryDotnetNewProject.Clean(); + MoveProjectJsonArtifactsToBackup(migrationReport); + return migrationReport.FailedProjectsCount; } + private void MoveProjectJsonArtifactsToBackup(MigrationReport migrationReport) + { + if (_skipBackup) + { + return; + } + + if (migrationReport.FailedProjectsCount > 0) + { + return; + } + + BackupGlobalJson(); + + BackupProjects(migrationReport); + + } + + private void BackupGlobalJson() + { + _backupDirectory.Create(); + + var globalJson = Path.Combine(_workspaceDirectory.FullName, GlobalSettings.FileName); + + if (File.Exists(globalJson)) + { + File.Move(globalJson, Path.Combine(_backupDirectory.FullName, GlobalSettings.FileName)); + } + } + + private void BackupProjects(MigrationReport migrationReport) + { + foreach (var report in migrationReport.ProjectMigrationReports) + { + MigrateProject(report); + } + } + + private void MigrateProject(ProjectMigrationReport report) + { + var projectDirectory = PathUtility.EnsureTrailingSlash(report.ProjectDirectory); + + var relativeDirectory = PathUtility.GetRelativePath(PathUtility.EnsureTrailingSlash(_workspaceDirectory.FullName), projectDirectory); + + var targetDirectory = String.IsNullOrEmpty(relativeDirectory) + ? _backupDirectory.FullName + : Path.Combine(_backupDirectory.FullName, relativeDirectory); + + PathUtility.EnsureDirectory(PathUtility.EnsureTrailingSlash(targetDirectory)); + + var movableFiles = new DirectoryInfo(projectDirectory) + .EnumerateFiles() + .Where(f => f.Name == Project.FileName || f.Extension == ".xproj"); + + foreach (var movableFile in movableFiles) + { + movableFile.MoveTo(Path.Combine(targetDirectory, movableFile.Name)); + } + } + private void WriteReport(MigrationReport migrationReport) { - if (!string.IsNullOrEmpty(_reportFile)) { using (var outputTextWriter = GetReportFileOutputTextWriter()) @@ -194,13 +265,14 @@ namespace Microsoft.DotNet.Tools.Migrate { IEnumerable projects = null; - if (projectArg.EndsWith(ProjectModel.FileName, StringComparison.OrdinalIgnoreCase)) + if (projectArg.EndsWith(Project.FileName, StringComparison.OrdinalIgnoreCase)) { projects = Enumerable.Repeat(projectArg, 1); } else if (projectArg.EndsWith(GlobalSettings.FileName, StringComparison.OrdinalIgnoreCase)) { projects = GetProjectsFromGlobalJson(projectArg); + if (!projects.Any()) { throw new Exception("Unable to find any projects in global.json"); @@ -208,8 +280,8 @@ namespace Microsoft.DotNet.Tools.Migrate } else if (Directory.Exists(projectArg)) { - projects = - Directory.EnumerateFiles(projectArg, ProjectModel.FileName, SearchOption.AllDirectories); + projects = Directory.EnumerateFiles(projectArg, Project.FileName, SearchOption.AllDirectories); + if (!projects.Any()) { throw new Exception($"No project.json file found in '{projectArg}'"); diff --git a/src/dotnet/commands/dotnet-migrate/Program.cs b/src/dotnet/commands/dotnet-migrate/Program.cs index b9d6ed49a..9bf4b9cee 100644 --- a/src/dotnet/commands/dotnet-migrate/Program.cs +++ b/src/dotnet/commands/dotnet-migrate/Program.cs @@ -42,7 +42,8 @@ namespace Microsoft.DotNet.Tools.Migrate CommandOption skipProjectReferences = app.Option("-s|--skip-project-references", "Skip migrating project references. By default project references are migrated recursively", CommandOptionType.BoolValue); CommandOption reportFile = app.Option("-r|--report-file", "Output migration report to a file in addition to the console.", CommandOptionType.SingleValue); - CommandOption structuredReportOutput = app.Option("--format-report-file-json", "Output migration report file as json rather than user messages", CommandOptionType.BoolValue); + CommandOption structuredReportOutput = app.Option("--format-report-file-json", "Output migration report file as json rather than user messages", CommandOptionType.BoolValue); + CommandOption skipBackup = app.Option("--skip-backup", "Skip moving project.json, global.json, and *.xproj to a `backup` directory after successful migration.", CommandOptionType.BoolValue); app.OnExecute(() => { @@ -53,7 +54,8 @@ namespace Microsoft.DotNet.Tools.Migrate xprojFile.Value(), reportFile.Value(), skipProjectReferences.BoolValue.HasValue ? skipProjectReferences.BoolValue.Value : false, - structuredReportOutput.BoolValue.HasValue ? structuredReportOutput.BoolValue.Value : false); + structuredReportOutput.BoolValue.HasValue ? structuredReportOutput.BoolValue.Value : false, + skipBackup.BoolValue.HasValue ? skipBackup.BoolValue.Value : false); return migrateCommand.Execute(); }); diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateAssemblyInfo.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateAssemblyInfo.cs index 1ca417c7e..eccfee86d 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateAssemblyInfo.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateAssemblyInfo.cs @@ -21,7 +21,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests public GivenThatIWantToMigrateAssemblyInfo() { var projectDirectory = - TestAssetsManager.CreateTestInstance("AppWithAssemblyInfo", callingMethod: "i").Path; + TestAssetsManager.CreateTestInstance("AppWithAssemblyInfo").Path; var projectContext = ProjectContext.Create(projectDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10); _mockProject = ProjectRootElement.Create(); diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoAssertions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoAssertions.cs index 9c8553276..fa068a90e 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoAssertions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoAssertions.cs @@ -30,11 +30,31 @@ namespace Microsoft.DotNet.Tools.Test.Utilities return new AndConstraint(this); } - public AndConstraint HaveFile(string expectedFile) + public AndConstraint HaveFile(string expectedFile, string because = "", params object[] reasonArgs) { var file = _dirInfo.EnumerateFiles(expectedFile, SearchOption.TopDirectoryOnly).SingleOrDefault(); - Execute.Assertion.ForCondition(file != null) - .FailWith("Expected File {0} cannot be found in directory {1}.", expectedFile, _dirInfo.FullName); + + Execute.Assertion + .ForCondition(file != null) + .BecauseOf(because, reasonArgs) + .FailWith($"Expected File {expectedFile} cannot be found in directory {_dirInfo.FullName}."); + + return new AndConstraint(this); + } + + public AndConstraint HaveTextFile(string expectedFile, string expectedContents, string because = "", params object[] reasonArgs) + { + this.HaveFile(expectedFile, because, reasonArgs); + + var file = _dirInfo.EnumerateFiles(expectedFile, SearchOption.TopDirectoryOnly).SingleOrDefault(); + + var contents = File.ReadAllText(file.FullName); + + Execute.Assertion + .ForCondition(contents.Equals(expectedContents)) + .BecauseOf(because, reasonArgs) + .FailWith($"Expected file {expectedFile} to contain \n\n{expectedContents}\n\nbut it contains\n\n{contents}\n"); + return new AndConstraint(this); } @@ -56,12 +76,26 @@ namespace Microsoft.DotNet.Tools.Test.Utilities return new AndConstraint(this); } - public AndConstraint HaveFilesMatching(string expectedFilesSearchPattern, SearchOption searchOption) + public AndConstraint HaveTextFiles(IDictionary expectedFiles, string because = "", params object[] reasonArgs) + { + foreach (var expectedFile in expectedFiles) + { + HaveTextFile(expectedFile.Key, expectedFile.Value, because, reasonArgs); + } + + return new AndConstraint(this); + } + + public AndConstraint HaveFilesMatching(string expectedFilesSearchPattern, SearchOption searchOption, string because = "", params object[] reasonArgs) { var matchingFileExists = _dirInfo.EnumerateFiles(expectedFilesSearchPattern, searchOption).Any(); - Execute.Assertion.ForCondition(matchingFileExists == true) + + Execute.Assertion + .ForCondition(matchingFileExists == true) + .BecauseOf(because, reasonArgs) .FailWith("Expected directory {0} to contain files matching {1}, but no matching file exists.", _dirInfo.FullName, expectedFilesSearchPattern); + return new AndConstraint(this); } @@ -108,5 +142,15 @@ namespace Microsoft.DotNet.Tools.Test.Utilities return new AndConstraint(this); } + + public AndConstraint NotExist(string because = "", params object[] reasonArgs) + { + Execute.Assertion + .ForCondition(_dirInfo.Exists == false) + .BecauseOf(because, reasonArgs) + .FailWith($"Expected directory {_dirInfo.FullName} to not exist, but it does."); + + return new AndConstraint(this); + } } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/MigrateCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/MigrateCommand.cs new file mode 100644 index 000000000..e3e87fd0e --- /dev/null +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/MigrateCommand.cs @@ -0,0 +1,29 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.DotNet.Cli.Utils; + +namespace Microsoft.DotNet.Tools.Test.Utilities +{ + public sealed class MigrateCommand : TestCommand + { + public MigrateCommand() + : base("dotnet") + { + + } + + public override CommandResult Execute(string args="") + { + args = $"migrate {args}"; + + return base.Execute(args); + } + + public override CommandResult ExecuteWithCapturedOutput(string args = "") + { + args = $"migrate {args}"; + return base.ExecuteWithCapturedOutput(args); + } + } +} diff --git a/test/dotnet-migrate.Tests/GivenThatAnAppWasMigrated.cs b/test/dotnet-migrate.Tests/GivenThatAnAppWasMigrated.cs new file mode 100644 index 000000000..a402ee770 --- /dev/null +++ b/test/dotnet-migrate.Tests/GivenThatAnAppWasMigrated.cs @@ -0,0 +1,111 @@ +using FluentAssertions; +using Microsoft.DotNet.TestFramework; +using Microsoft.DotNet.Tools.Common; +using Microsoft.DotNet.Tools.Test.Utilities; +using System; +using System.Collections.Generic; +using System.IO; +using Xunit; + +namespace Microsoft.DotNet.Migration.Tests +{ + public class GivenThatAnAppWasMigrated : TestBase + { + [Theory] + [InlineData("PJTestAppSimple")] + [InlineData("TestAppWithLibrary")] + public void When_migration_succeeds_Then_project_json_artifacts_get_moved_to_backup(string testProjectName) + { + var testRoot = TestAssetsManager + .CreateTestInstance(testProjectName, identifier: testProjectName) + .Path; + + var backupRoot = Path.Combine(testRoot, "backup"); + + var migratableArtifacts = GetProjectJsonArtifacts(testRoot); + + new MigrateCommand() + .WithWorkingDirectory(testRoot) + .Execute() + .Should().Pass(); + + var backupArtifacts = GetProjectJsonArtifacts(backupRoot); + + backupArtifacts.Should().Equal(migratableArtifacts, "Because all of and only these artifacts should have been moved"); + + new DirectoryInfo(testRoot).Should().NotHaveFiles(backupArtifacts.Keys); + + new DirectoryInfo(backupRoot).Should().HaveTextFiles(backupArtifacts); + } + + [Theory] + [InlineData("TestAppWithLibraryAndMissingP2P")] + public void When_migration_fails_Then_project_json_artifacts_do_not_get_moved_to_backup(string testProjectName) + { + var testRoot = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets", "NonRestoredTestProjects")) + .CreateTestInstance(testProjectName, identifier: testProjectName) + .Path; + + var backupRoot = Path.Combine(testRoot, "backup"); + + var migratableArtifacts = GetProjectJsonArtifacts(testRoot); + + new MigrateCommand() + .WithWorkingDirectory(testRoot) + .Execute() + .Should().Fail(); + + new DirectoryInfo(backupRoot).Should().NotExist("Because migration failed and therefore no backup is needed."); + + new DirectoryInfo(testRoot).Should().HaveTextFiles(migratableArtifacts, "Because migration failed so nothing was moved to backup."); + } + + [Theory] + [InlineData("PJTestAppSimple")] + public void When_skipbackup_specified_Then_project_json_artifacts_do_not_get_moved_to_backup(string testProjectName) + { + var testRoot = TestAssetsManager.CreateTestInstance(testProjectName, identifier: testProjectName).Path; + + var backupRoot = Path.Combine(testRoot, "backup"); + + var migratableArtifacts = GetProjectJsonArtifacts(testRoot); + + new MigrateCommand() + .WithWorkingDirectory(testRoot) + .Execute("--skip-backup") + .Should().Pass(); + + new DirectoryInfo(backupRoot).Should().NotExist("Because --skip-backup was specified."); + + new DirectoryInfo(testRoot).Should().HaveTextFiles(migratableArtifacts, "Because --skip-backup was specified."); + } + + private Dictionary GetProjectJsonArtifacts(string rootPath) + { + var catalog = new Dictionary(); + + var patterns = new [] { "global.json", "project.json", "*.xproj" }; + + foreach (var pattern in patterns) + { + AddArtifactsToCatalog(catalog, rootPath, pattern); + } + + return catalog; + } + + private void AddArtifactsToCatalog(Dictionary catalog, string basePath, string pattern) + { + basePath = PathUtility.EnsureTrailingSlash(basePath); + + var baseDirectory = new DirectoryInfo(basePath); + + var files = baseDirectory.GetFiles(pattern, SearchOption.AllDirectories); + + foreach (var file in files) + { + catalog.Add(PathUtility.GetRelativePath(basePath, file.FullName), File.ReadAllText(file.FullName)); + } + } + } +} diff --git a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs index 87d0a3080..abd6e22b8 100644 --- a/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs +++ b/test/dotnet-migrate.Tests/GivenThatIWantToMigrateTestApps.cs @@ -12,6 +12,8 @@ using BuildCommand = Microsoft.DotNet.Tools.Test.Utilities.BuildCommand; using System.Runtime.Loader; using Newtonsoft.Json.Linq; +using MigrateCommand = Microsoft.DotNet.Tools.Migrate.MigrateCommand; + namespace Microsoft.DotNet.Migration.Tests { public class GivenThatIWantToMigrateTestApps : TestBase @@ -354,9 +356,10 @@ namespace Microsoft.DotNet.Migration.Tests public void It_migrates_and_publishes_projects_with_runtimes() { var projectName = "PJTestAppSimple"; - var projectDirectory = TestAssetsManager.CreateTestInstance(projectName, callingMethod: "i") - .WithLockFiles() - .Path; + var projectDirectory = TestAssetsManager + .CreateTestInstance(projectName) + .WithLockFiles() + .Path; CleanBinObj(projectDirectory); BuildProjectJsonMigrateBuildMSBuild(projectDirectory, projectName); @@ -440,7 +443,7 @@ namespace Microsoft.DotNet.Migration.Tests private void VerifyMigration(IEnumerable expectedProjects, string rootDir) { - var migratedProjects = Directory.EnumerateFiles(rootDir, "project.json", SearchOption.AllDirectories) + var migratedProjects = Directory.EnumerateFiles(rootDir, "*.csproj", 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)));