Merge pull request #4733 from livarcocc/migrate_adds_rids_for_desktop
Emitting runtime identifiers if the source project has any full framework TFMs
This commit is contained in:
commit
11f871b715
2 changed files with 50 additions and 0 deletions
|
@ -15,6 +15,9 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
// TODO: Support Multi-TFM
|
// TODO: Support Multi-TFM
|
||||||
internal class MigrateTFMRule : IMigrationRule
|
internal class MigrateTFMRule : IMigrationRule
|
||||||
{
|
{
|
||||||
|
private const string RuntimeIdentifiers =
|
||||||
|
"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";
|
||||||
|
|
||||||
private readonly ITransformApplicator _transformApplicator;
|
private readonly ITransformApplicator _transformApplicator;
|
||||||
|
|
||||||
public MigrateTFMRule(ITransformApplicator transformApplicator = null)
|
public MigrateTFMRule(ITransformApplicator transformApplicator = null)
|
||||||
|
@ -37,6 +40,11 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
migrationRuleInputs.ProjectContexts.Single().TargetFramework),
|
migrationRuleInputs.ProjectContexts.Single().TargetFramework),
|
||||||
propertyGroup,
|
propertyGroup,
|
||||||
mergeExisting: true);
|
mergeExisting: true);
|
||||||
|
_transformApplicator.Execute(
|
||||||
|
FrameworkRuntimeIdentifiersTransform.Transform(
|
||||||
|
migrationRuleInputs.ProjectContexts.Single().TargetFramework),
|
||||||
|
propertyGroup,
|
||||||
|
mergeExisting: true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -45,6 +53,11 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
migrationRuleInputs.ProjectContexts.Select(p => p.TargetFramework)),
|
migrationRuleInputs.ProjectContexts.Select(p => p.TargetFramework)),
|
||||||
propertyGroup,
|
propertyGroup,
|
||||||
mergeExisting: true);
|
mergeExisting: true);
|
||||||
|
_transformApplicator.Execute(
|
||||||
|
FrameworksRuntimeIdentifiersTransform.Transform(
|
||||||
|
migrationRuleInputs.ProjectContexts.Select(p => p.TargetFramework)),
|
||||||
|
propertyGroup,
|
||||||
|
mergeExisting: true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,10 +122,22 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
frameworks => string.Join(";", frameworks.Select(f => f.GetShortFolderName())),
|
frameworks => string.Join(";", frameworks.Select(f => f.GetShortFolderName())),
|
||||||
frameworks => true);
|
frameworks => true);
|
||||||
|
|
||||||
|
private AddPropertyTransform<IEnumerable<NuGetFramework>> FrameworksRuntimeIdentifiersTransform =>
|
||||||
|
new AddPropertyTransform<IEnumerable<NuGetFramework>>(
|
||||||
|
"RuntimeIdentifiers",
|
||||||
|
frameworks => RuntimeIdentifiers,
|
||||||
|
frameworks => frameworks.Any(f => !f.IsPackageBased));
|
||||||
|
|
||||||
private AddPropertyTransform<NuGetFramework> FrameworkTransform =>
|
private AddPropertyTransform<NuGetFramework> FrameworkTransform =>
|
||||||
new AddPropertyTransform<NuGetFramework>(
|
new AddPropertyTransform<NuGetFramework>(
|
||||||
"TargetFramework",
|
"TargetFramework",
|
||||||
framework => framework.GetShortFolderName(),
|
framework => framework.GetShortFolderName(),
|
||||||
framework => true);
|
framework => true);
|
||||||
|
|
||||||
|
private AddPropertyTransform<NuGetFramework> FrameworkRuntimeIdentifiersTransform =>
|
||||||
|
new AddPropertyTransform<NuGetFramework>(
|
||||||
|
"RuntimeIdentifiers",
|
||||||
|
framework => RuntimeIdentifiers,
|
||||||
|
framework => !framework.IsPackageBased);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,31 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
.Value.Should().Be("net20;net35;net40;net461;netstandard1.5");
|
.Value.Should().Be("net20;net35;net40;net461;netstandard1.5");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Migrating_desktop_TFMs_adds_RuntimeIdentifiers()
|
||||||
|
{
|
||||||
|
var testDirectory = Temp.CreateDirectory().Path;
|
||||||
|
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
||||||
|
.FromTestAssetBase("TestLibraryWithMultipleFrameworks")
|
||||||
|
.SaveToDisk(testDirectory);
|
||||||
|
|
||||||
|
var projectContexts = ProjectContext.CreateContextForEachFramework(testDirectory);
|
||||||
|
var mockProj = ProjectRootElement.Create();
|
||||||
|
|
||||||
|
var migrationSettings = new MigrationSettings(testDirectory, testDirectory, "1.0.0", mockProj);
|
||||||
|
var migrationInputs = new MigrationRuleInputs(
|
||||||
|
projectContexts,
|
||||||
|
mockProj,
|
||||||
|
mockProj.AddItemGroup(),
|
||||||
|
mockProj.AddPropertyGroup());
|
||||||
|
|
||||||
|
new MigrateTFMRule().Apply(migrationSettings, migrationInputs);
|
||||||
|
|
||||||
|
mockProj.Properties.Count(p => p.Name == "RuntimeIdentifiers").Should().Be(1);
|
||||||
|
mockProj.Properties.First(p => p.Name == "RuntimeIdentifiers")
|
||||||
|
.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]
|
[Fact]
|
||||||
public void Migrating_Single_TFM_project_Populates_TargetFramework()
|
public void Migrating_Single_TFM_project_Populates_TargetFramework()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue