Merge pull request #5758 from livarcocc/migrate_full_framework_no_runtime
No longer add runtime identifier when migrating apps that contain full framework
This commit is contained in:
commit
7238b3efa2
2 changed files with 5 additions and 73 deletions
|
@ -50,15 +50,6 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
propertyGroup,
|
propertyGroup,
|
||||||
mergeExisting: true);
|
mergeExisting: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
_transformApplicator.Execute(
|
|
||||||
RuntimeIdentifiersTransform.Transform(migrationRuleInputs.ProjectContexts),
|
|
||||||
propertyGroup,
|
|
||||||
mergeExisting: true);
|
|
||||||
_transformApplicator.Execute(
|
|
||||||
RuntimeIdentifierTransform.Transform(migrationRuleInputs.ProjectContexts),
|
|
||||||
propertyGroup,
|
|
||||||
mergeExisting: true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CleanExistingProperties(ProjectRootElement csproj)
|
private void CleanExistingProperties(ProjectRootElement csproj)
|
||||||
|
@ -127,36 +118,5 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
"TargetFramework",
|
"TargetFramework",
|
||||||
framework => framework.GetShortFolderName(),
|
framework => framework.GetShortFolderName(),
|
||||||
framework => true);
|
framework => true);
|
||||||
|
|
||||||
private AddPropertyTransform<IEnumerable<ProjectContext>> RuntimeIdentifiersTransform =>
|
|
||||||
new AddPropertyTransform<IEnumerable<ProjectContext>>(
|
|
||||||
"RuntimeIdentifiers",
|
|
||||||
projectContexts => RuntimeIdentifiers,
|
|
||||||
projectContexts => !projectContexts.HasRuntimes() &&
|
|
||||||
!projectContexts.HasLibraryOutput() &&
|
|
||||||
projectContexts.HasBothCoreAndFullFrameworkTFMs());
|
|
||||||
|
|
||||||
private AddPropertyTransform<IEnumerable<ProjectContext>> RuntimeIdentifierTransform =>
|
|
||||||
new AddPropertyTransform<IEnumerable<ProjectContext>>(
|
|
||||||
"RuntimeIdentifier",
|
|
||||||
projectContexts => "win7-x86",
|
|
||||||
projectContexts => !projectContexts.HasRuntimes() &&
|
|
||||||
!projectContexts.HasLibraryOutput() &&
|
|
||||||
projectContexts.HasFullFrameworkTFM())
|
|
||||||
.WithMSBuildCondition(projectContexts =>
|
|
||||||
{
|
|
||||||
string msBuildCondition = null;
|
|
||||||
if (projectContexts.HasBothCoreAndFullFrameworkTFMs())
|
|
||||||
{
|
|
||||||
msBuildCondition = string.Join(
|
|
||||||
" OR ",
|
|
||||||
projectContexts.Where(p => p.IsFullFramework()).Select(
|
|
||||||
p => $"'$(TargetFramework)' == '{p.TargetFramework.GetShortFolderName()}'"));
|
|
||||||
|
|
||||||
msBuildCondition = $" {msBuildCondition} ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return msBuildCondition;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void MigratingCoreAndDesktopTFMsAddsAllRuntimeIdentifiersIfTheProjectDoesNothaveAnyAlready()
|
public void MigratingCoreAndDesktopTFMsDoesNoAddRuntimeIdentifiersOrRuntimeIdentifierWhenTheProjectDoesNothaveAnyAlready()
|
||||||
{
|
{
|
||||||
var testDirectory = Temp.CreateDirectory().Path;
|
var testDirectory = Temp.CreateDirectory().Path;
|
||||||
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
||||||
|
@ -88,35 +88,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
|
|
||||||
new MigrateTFMRule().Apply(migrationSettings, migrationInputs);
|
new MigrateTFMRule().Apply(migrationSettings, migrationInputs);
|
||||||
|
|
||||||
mockProj.Properties.Count(p => p.Name == "RuntimeIdentifiers").Should().Be(1);
|
mockProj.Properties.Count(p => p.Name == "RuntimeIdentifiers").Should().Be(0);
|
||||||
mockProj.Properties.First(p => p.Name == "RuntimeIdentifiers")
|
mockProj.Properties.Count(p => p.Name == "RuntimeIdentifier").Should().Be(0);
|
||||||
.Value.Should().Be("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");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void MigratingCoreAndDesktopTFMsAddsRuntimeIdentifierWithWin7x86ConditionOnAllFullFrameworksWhenNoRuntimesExistAlready()
|
|
||||||
{
|
|
||||||
var testDirectory = Temp.CreateDirectory().Path;
|
|
||||||
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
|
||||||
.FromTestAssetBase("PJAppWithMultipleFrameworks")
|
|
||||||
.SaveToDisk(testDirectory);
|
|
||||||
|
|
||||||
var projectContexts = ProjectContext.CreateContextForEachFramework(testDirectory);
|
|
||||||
var mockProj = ProjectRootElement.Create();
|
|
||||||
|
|
||||||
var migrationSettings = MigrationSettings.CreateMigrationSettingsTestHook(testDirectory, testDirectory, mockProj);
|
|
||||||
var migrationInputs = new MigrationRuleInputs(
|
|
||||||
projectContexts,
|
|
||||||
mockProj,
|
|
||||||
mockProj.AddItemGroup(),
|
|
||||||
mockProj.AddPropertyGroup());
|
|
||||||
|
|
||||||
new MigrateTFMRule().Apply(migrationSettings, migrationInputs);
|
|
||||||
|
|
||||||
mockProj.Properties.Count(p => p.Name == "RuntimeIdentifier").Should().Be(1);
|
|
||||||
var runtimeIdentifier = mockProj.Properties.First(p => p.Name == "RuntimeIdentifier");
|
|
||||||
runtimeIdentifier.Value.Should().Be("win7-x86");
|
|
||||||
runtimeIdentifier.Condition.Should().Be(" '$(TargetFramework)' == 'net20' OR '$(TargetFramework)' == 'net35' OR '$(TargetFramework)' == 'net40' OR '$(TargetFramework)' == 'net461' ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -144,7 +117,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void MigratingProjectWithFullFrameworkTFMsOnlyAddsARuntimeIdentifierWin7x86WhenNoRuntimesExistAlready()
|
public void MigratingProjectWithFullFrameworkTFMsDoesNotAddRuntimeIdentifiersOrRuntimeIdentiferWhenNoRuntimesExistAlready()
|
||||||
{
|
{
|
||||||
var testDirectory = Temp.CreateDirectory().Path;
|
var testDirectory = Temp.CreateDirectory().Path;
|
||||||
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
||||||
|
@ -165,8 +138,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
new MigrateTFMRule().Apply(migrationSettings, migrationInputs);
|
new MigrateTFMRule().Apply(migrationSettings, migrationInputs);
|
||||||
|
|
||||||
mockProj.Properties.Count(p => p.Name == "RuntimeIdentifiers").Should().Be(0);
|
mockProj.Properties.Count(p => p.Name == "RuntimeIdentifiers").Should().Be(0);
|
||||||
mockProj.Properties.Where(p => p.Name == "RuntimeIdentifier").Should().HaveCount(1);
|
mockProj.Properties.Where(p => p.Name == "RuntimeIdentifier").Should().HaveCount(0);
|
||||||
mockProj.Properties.Single(p => p.Name == "RuntimeIdentifier").Value.Should().Be("win7-x86");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue