Removing TFM specific defines for migrated projects, since they are not being set in the SDK itself.

This commit is contained in:
Livar Cunha 2016-11-02 15:05:45 -07:00
parent 0c833f5349
commit 4e1f2f2b20
2 changed files with 15 additions and 34 deletions

View file

@ -504,12 +504,6 @@ namespace Microsoft.DotNet.Internal.ProjectModel
// Add the target framework specific define
var defines = new HashSet<string>(compilerOptions.Defines ?? Enumerable.Empty<string>());
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);

View file

@ -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()
{