diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/MigrationErrorCodes.cs b/src/Microsoft.DotNet.ProjectJsonMigration/MigrationErrorCodes.cs index efc00d476..df8f1c186 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/MigrationErrorCodes.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/MigrationErrorCodes.cs @@ -24,6 +24,9 @@ namespace Microsoft.DotNet.ProjectJsonMigration public static Func MIGRATE1016 => (message) => new MigrationError(nameof(MIGRATE1016), "Unsupported Script Variable", message); + public static Func MIGRATE1017 + => (message) => new MigrationError(nameof(MIGRATE1017), "Multiple Xproj Files", message); + // Potentially Temporary (Point in Time) Errors public static Func MIGRATE20011 => (message) => new MigrationError(nameof(MIGRATE20011), "Multi-TFM", message); diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs index 05a1d06dc..5ffe24deb 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/ProjectMigrator.cs @@ -72,7 +72,9 @@ namespace Microsoft.DotNet.ProjectJsonMigration if (allXprojFiles.Count() > 1) { - throw new Exception("Multiple xproj files found in {projectDirectory}, please specify which to use"); + MigrationErrorCodes + .MIGRATE1017($"Multiple xproj files found in {projectDirectory}, please specify which to use") + .Throw(); } return allXprojFiles.FirstOrDefault(); diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateProjectDependencies.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateProjectDependencies.cs index f5cb968cc..5170eda59 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateProjectDependencies.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateProjectDependencies.cs @@ -116,6 +116,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests migratedProjectReferenceItems.Select(m => m.Include).Should().BeEquivalentTo(expectedMigratedReferences); } + [Fact] public void It_migrates_csproj_ProjectReference_in_xproj_including_condition_on_ProjectReference() { var projectReference = "some/to.csproj"; @@ -149,6 +150,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests migratedProjectReferenceItem.Condition.Should().Be(" '$(Foo)' == 'bar' "); } + [Fact] public void It_migrates_csproj_ProjectReference_in_xproj_including_condition_on_ProjectReference_parent() { var projectReference = "some/to.csproj"; @@ -182,6 +184,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests migratedProjectReferenceItem.Condition.Should().Be(" '$(Foo)' == 'bar' "); } + [Fact] public void It_migrates_csproj_ProjectReference_in_xproj_including_condition_on_ProjectReference_parent_and_item() { var projectReference = "some/to.csproj"; diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateTFMs.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateTFMs.cs index 45e58436f..d95877ff9 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateTFMs.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateTFMs.cs @@ -43,6 +43,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests mockProj.Properties.Count(p => p.Name == "TargetFrameworkVersion").Should().Be(0); } + [Fact] public void Migrating_MultiTFM_project_Populates_TargetFrameworks_with_short_tfms() { var testDirectory = Temp.CreateDirectory().Path; @@ -67,6 +68,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests .Value.Should().Be("net20;net35;net40;net461;netstandard1.5"); } + [Fact] public void Migrating_Single_TFM_project_Populates_TargetFrameworks_with_short_tfm() { var testDirectory = Temp.CreateDirectory().Path;