diff --git a/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs index c5b67bf17..d3ac59047 100644 --- a/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs +++ b/src/Microsoft.DotNet.ProjectJsonMigration/Microsoft.DotNet.Internal.ProjectModel/ProjectReader.cs @@ -504,12 +504,6 @@ namespace Microsoft.DotNet.Internal.ProjectModel // Add the target framework specific define var defines = new HashSet(compilerOptions.Defines ?? Enumerable.Empty()); - var frameworkDefine = MakeDefaultTargetFrameworkDefine(frameworkName); - - if (!string.IsNullOrEmpty(frameworkDefine)) - { - defines.Add(frameworkDefine); - } compilerOptions.Defines = defines; @@ -806,34 +800,6 @@ namespace Microsoft.DotNet.Internal.ProjectModel return null; } - private static string MakeDefaultTargetFrameworkDefine(NuGetFramework targetFramework) - { - var shortName = targetFramework.GetTwoDigitShortFolderName(); - - if (targetFramework.IsPCL) - { - return null; - } - - var candidateName = shortName.ToUpperInvariant(); - - // Replace '-', '.', and '+' in the candidate name with '_' because TFMs with profiles use those (like "net40-client") - // and we want them representable as defines (i.e. "NET40_CLIENT") - candidateName = candidateName.Replace('-', '_').Replace('+', '_').Replace('.', '_'); - - // We require the following from our Target Framework Define names - // Starts with A-Z or _ - // Contains only A-Z, 0-9 and _ - if (!string.IsNullOrEmpty(candidateName) && - (char.IsLetter(candidateName[0]) || candidateName[0] == '_') && - candidateName.All(c => Char.IsLetterOrDigit(c) || c == '_')) - { - return candidateName; - } - - return null; - } - private static bool HasProjectFile(string path) { string projectPath = Path.Combine(path, Project.FileName); diff --git a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateConfigurations.cs b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateConfigurations.cs index b5033280c..a287d7961 100644 --- a/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateConfigurations.cs +++ b/test/Microsoft.DotNet.ProjectJsonMigration.Tests/Rules/GivenThatIWantToMigrateConfigurations.cs @@ -62,6 +62,21 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests .Contain("'$(TargetFramework)' == 'netcoreapp1.0'"); } + [Fact] + public void It_does_not_add_a_define_for_the_framework() + { + var mockProj = RunConfigurationsRuleOnPj(@" + { + ""frameworks"": { + ""netcoreapp1.0"": { + } + } + }"); + + mockProj.Properties.Count( + prop => prop.Name == "DefineConstants" && prop.Value.Contains("NETCOREAPP1_0")).Should().Be(0); + } + [Fact] public void Configuration_buildOptions_properties_are_not_written_when_they_overlap_with_buildOptions() {