Only adding rids for full framework TFMs if the project.json does not already have Runtimes in its Runtimes section.
This commit is contained in:
parent
9c3141b63f
commit
b2ce6c794a
5 changed files with 101 additions and 14 deletions
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
|
namespace ConsoleApplication
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello World!");
|
||||||
|
#if NET20 || NET35 || NET45 || NET461
|
||||||
|
// Force XmlDocument to be used
|
||||||
|
var doc = new XmlDocument();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"buildOptions": {
|
||||||
|
"emitEntryPoint": true
|
||||||
|
},
|
||||||
|
"dependencies": {},
|
||||||
|
"frameworks": {
|
||||||
|
"net20": {
|
||||||
|
"frameworkAssemblies": {
|
||||||
|
"System.Xml": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"net35": {
|
||||||
|
"frameworkAssemblies": {
|
||||||
|
"System.Xml": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"net40": {
|
||||||
|
"frameworkAssemblies": {
|
||||||
|
"System.Xml": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"net461": {
|
||||||
|
"frameworkAssemblies": {
|
||||||
|
"System.Xml": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"netcoreapp1.0": {
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NetCore.App": "1.0.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"runtimes": {
|
||||||
|
"win7-x64": {},
|
||||||
|
"win7-x86": {}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.Build.Construction;
|
using Microsoft.Build.Construction;
|
||||||
|
using Microsoft.DotNet.Internal.ProjectModel;
|
||||||
using Microsoft.DotNet.ProjectJsonMigration.Transforms;
|
using Microsoft.DotNet.ProjectJsonMigration.Transforms;
|
||||||
using NuGet.Frameworks;
|
using NuGet.Frameworks;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -42,7 +43,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
mergeExisting: true);
|
mergeExisting: true);
|
||||||
_transformApplicator.Execute(
|
_transformApplicator.Execute(
|
||||||
FrameworkRuntimeIdentifiersTransform.Transform(
|
FrameworkRuntimeIdentifiersTransform.Transform(
|
||||||
migrationRuleInputs.ProjectContexts.Single().TargetFramework),
|
migrationRuleInputs.ProjectContexts.Single()),
|
||||||
propertyGroup,
|
propertyGroup,
|
||||||
mergeExisting: true);
|
mergeExisting: true);
|
||||||
}
|
}
|
||||||
|
@ -53,9 +54,14 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
migrationRuleInputs.ProjectContexts.Select(p => p.TargetFramework)),
|
migrationRuleInputs.ProjectContexts.Select(p => p.TargetFramework)),
|
||||||
propertyGroup,
|
propertyGroup,
|
||||||
mergeExisting: true);
|
mergeExisting: true);
|
||||||
|
|
||||||
|
|
||||||
|
var runtimes = string.Join(",", migrationRuleInputs.ProjectContexts.Select(p => p.RuntimeIdentifier));
|
||||||
|
Console.WriteLine($"Runtimes = {runtimes}");
|
||||||
|
|
||||||
_transformApplicator.Execute(
|
_transformApplicator.Execute(
|
||||||
FrameworksRuntimeIdentifiersTransform.Transform(
|
FrameworksRuntimeIdentifiersTransform.Transform(
|
||||||
migrationRuleInputs.ProjectContexts.Select(p => p.TargetFramework)),
|
migrationRuleInputs.ProjectContexts),
|
||||||
propertyGroup,
|
propertyGroup,
|
||||||
mergeExisting: true);
|
mergeExisting: true);
|
||||||
}
|
}
|
||||||
|
@ -122,11 +128,12 @@ 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 =>
|
private AddPropertyTransform<IEnumerable<ProjectContext>> FrameworksRuntimeIdentifiersTransform =>
|
||||||
new AddPropertyTransform<IEnumerable<NuGetFramework>>(
|
new AddPropertyTransform<IEnumerable<ProjectContext>>(
|
||||||
"RuntimeIdentifiers",
|
"RuntimeIdentifiers",
|
||||||
frameworks => RuntimeIdentifiers,
|
projectContexts => RuntimeIdentifiers,
|
||||||
frameworks => frameworks.Any(f => !f.IsPackageBased));
|
projectContexts => projectContexts.All(p => !p.ProjectFile.Runtimes.Any()) &&
|
||||||
|
projectContexts.Any(p => !p.TargetFramework.IsPackageBased));
|
||||||
|
|
||||||
private AddPropertyTransform<NuGetFramework> FrameworkTransform =>
|
private AddPropertyTransform<NuGetFramework> FrameworkTransform =>
|
||||||
new AddPropertyTransform<NuGetFramework>(
|
new AddPropertyTransform<NuGetFramework>(
|
||||||
|
@ -134,10 +141,11 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
framework => framework.GetShortFolderName(),
|
framework => framework.GetShortFolderName(),
|
||||||
framework => true);
|
framework => true);
|
||||||
|
|
||||||
private AddPropertyTransform<NuGetFramework> FrameworkRuntimeIdentifiersTransform =>
|
private AddPropertyTransform<ProjectContext> FrameworkRuntimeIdentifiersTransform =>
|
||||||
new AddPropertyTransform<NuGetFramework>(
|
new AddPropertyTransform<ProjectContext>(
|
||||||
"RuntimeIdentifiers",
|
"RuntimeIdentifiers",
|
||||||
framework => RuntimeIdentifiers,
|
projectContext => RuntimeIdentifiers,
|
||||||
framework => !framework.IsPackageBased);
|
projectContext => !projectContext.ProjectFile.Runtimes.Any() &&
|
||||||
|
!projectContext.TargetFramework.IsPackageBased);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
public class GivenThatIWantToMigrateTFMs : TestBase
|
public class GivenThatIWantToMigrateTFMs : TestBase
|
||||||
{
|
{
|
||||||
[Fact(Skip="Emitting this until x-targetting full support is in")]
|
[Fact(Skip="Emitting this until x-targetting full support is in")]
|
||||||
public void Migrating_netcoreapp_project_Does_not_populate_TargetFrameworkIdentifier_and_TargetFrameworkVersion()
|
public void MigratingNetcoreappProjectDoesNotPopulateTargetFrameworkIdentifierAndTargetFrameworkVersion()
|
||||||
{
|
{
|
||||||
var testDirectory = Temp.CreateDirectory().Path;
|
var testDirectory = Temp.CreateDirectory().Path;
|
||||||
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
||||||
|
@ -44,7 +44,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Migrating_MultiTFM_project_Populates_TargetFrameworks_with_short_tfms()
|
public void MigratingMultiTFMProjectPopulatesTargetFrameworksWithShortTfms()
|
||||||
{
|
{
|
||||||
var testDirectory = Temp.CreateDirectory().Path;
|
var testDirectory = Temp.CreateDirectory().Path;
|
||||||
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
||||||
|
@ -69,7 +69,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Migrating_desktop_TFMs_adds_RuntimeIdentifiers()
|
public void MigratingDesktopTFMsAddsAllRuntimeIdentifiersIfTheProjectDoesNothaveAnyAlready()
|
||||||
{
|
{
|
||||||
var testDirectory = Temp.CreateDirectory().Path;
|
var testDirectory = Temp.CreateDirectory().Path;
|
||||||
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
||||||
|
@ -94,7 +94,31 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Migrating_Single_TFM_project_Populates_TargetFramework()
|
public void MigrateTFMRuleDoesNotAddRuntimesWhenMigratingDesktopTFMsWithRuntimesAlready()
|
||||||
|
{
|
||||||
|
var testDirectory = Temp.CreateDirectory().Path;
|
||||||
|
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
||||||
|
.FromTestAssetBase("TestAppWithMultipleFrameworksAndRuntimes")
|
||||||
|
.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 == "RuntimeIdentifiers").Should().Be(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void MigratingSingleTFMProjectPopulatesTargetFramework()
|
||||||
{
|
{
|
||||||
var testDirectory = Temp.CreateDirectory().Path;
|
var testDirectory = Temp.CreateDirectory().Path;
|
||||||
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
|
||||||
|
|
Loading…
Reference in a new issue