Merge pull request #4589 from livarcocc/cleanup_migration
Cleanup migration
This commit is contained in:
commit
d84c89be15
4 changed files with 21 additions and 38 deletions
|
@ -504,12 +504,6 @@ namespace Microsoft.DotNet.Internal.ProjectModel
|
||||||
|
|
||||||
// Add the target framework specific define
|
// Add the target framework specific define
|
||||||
var defines = new HashSet<string>(compilerOptions.Defines ?? Enumerable.Empty<string>());
|
var defines = new HashSet<string>(compilerOptions.Defines ?? Enumerable.Empty<string>());
|
||||||
var frameworkDefine = MakeDefaultTargetFrameworkDefine(frameworkName);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(frameworkDefine))
|
|
||||||
{
|
|
||||||
defines.Add(frameworkDefine);
|
|
||||||
}
|
|
||||||
|
|
||||||
compilerOptions.Defines = defines;
|
compilerOptions.Defines = defines;
|
||||||
|
|
||||||
|
@ -806,34 +800,6 @@ namespace Microsoft.DotNet.Internal.ProjectModel
|
||||||
return null;
|
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)
|
private static bool HasProjectFile(string path)
|
||||||
{
|
{
|
||||||
string projectPath = Path.Combine(path, Project.FileName);
|
string projectPath = Path.Combine(path, Project.FileName);
|
||||||
|
|
|
@ -131,6 +131,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
(compilerOptions, projectDirectory) =>
|
(compilerOptions, projectDirectory) =>
|
||||||
CopyToOutputFilesTransform.Transform(GetCopyToOutputIncludeContext(compilerOptions, projectDirectory));
|
CopyToOutputFilesTransform.Transform(GetCopyToOutputIncludeContext(compilerOptions, projectDirectory));
|
||||||
|
|
||||||
|
private readonly string[] DefaultEmptyExcludeOption = new string[0];
|
||||||
|
|
||||||
private readonly ProjectPropertyGroupElement _configurationPropertyGroup;
|
private readonly ProjectPropertyGroupElement _configurationPropertyGroup;
|
||||||
private readonly ProjectItemGroupElement _configurationItemGroup;
|
private readonly ProjectItemGroupElement _configurationItemGroup;
|
||||||
private readonly CommonCompilerOptions _configurationBuildOptions;
|
private readonly CommonCompilerOptions _configurationBuildOptions;
|
||||||
|
@ -328,7 +330,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
"compile",
|
"compile",
|
||||||
new JObject(),
|
new JObject(),
|
||||||
ProjectFilesCollection.DefaultCompileBuiltInPatterns,
|
ProjectFilesCollection.DefaultCompileBuiltInPatterns,
|
||||||
ProjectFilesCollection.DefaultBuiltInExcludePatterns);
|
DefaultEmptyExcludeOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IncludeContext GetEmbedIncludeContext(CommonCompilerOptions compilerOptions, string projectDirectory)
|
private IncludeContext GetEmbedIncludeContext(CommonCompilerOptions compilerOptions, string projectDirectory)
|
||||||
|
@ -340,7 +342,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
"embed",
|
"embed",
|
||||||
new JObject(),
|
new JObject(),
|
||||||
ProjectFilesCollection.DefaultResourcesBuiltInPatterns,
|
ProjectFilesCollection.DefaultResourcesBuiltInPatterns,
|
||||||
ProjectFilesCollection.DefaultBuiltInExcludePatterns);
|
DefaultEmptyExcludeOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IncludeContext GetCopyToOutputIncludeContext(CommonCompilerOptions compilerOptions, string projectDirectory)
|
private IncludeContext GetCopyToOutputIncludeContext(CommonCompilerOptions compilerOptions, string projectDirectory)
|
||||||
|
|
|
@ -58,9 +58,9 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
|
|
||||||
mockProj.Items.Count().Should().Be(2);
|
mockProj.Items.Count().Should().Be(2);
|
||||||
mockProj.Items.First(i => i.ItemType == "Compile").Include.Should().Be(@"**\*.cs");
|
mockProj.Items.First(i => i.ItemType == "Compile").Include.Should().Be(@"**\*.cs");
|
||||||
mockProj.Items.First(i => i.ItemType == "Compile").Exclude.Should().Be(@"bin\**;obj\**;**\*.xproj;packages\**");
|
mockProj.Items.First(i => i.ItemType == "Compile").Exclude.Should().BeEmpty();
|
||||||
mockProj.Items.First(i => i.ItemType == "EmbeddedResource").Include.Should().Be(@"compiler\resources\**\*;**\*.resx");
|
mockProj.Items.First(i => i.ItemType == "EmbeddedResource").Include.Should().Be(@"compiler\resources\**\*;**\*.resx");
|
||||||
mockProj.Items.First(i => i.ItemType == "EmbeddedResource").Exclude.Should().Be(@"bin\**;obj\**;**\*.xproj;packages\**");
|
mockProj.Items.First(i => i.ItemType == "EmbeddedResource").Exclude.Should().BeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
@ -62,6 +62,21 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
.Contain("'$(TargetFramework)' == 'netcoreapp1.0'");
|
.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]
|
[Fact]
|
||||||
public void Configuration_buildOptions_properties_are_not_written_when_they_overlap_with_buildOptions()
|
public void Configuration_buildOptions_properties_are_not_written_when_they_overlap_with_buildOptions()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue