3a9525b5ac
* rel/1.0.1: (66 commits) Update LZMA license with correct text Bump to 2.0.0-rc5-61427-04 Remove duplicate installer suffix Add license text to LZMA SDK license notice Updating the SDK to 1.0.0-alpha-20170224-6 Updating both platform abstractions and dependency model to 1.0.3. Bump Roslyn to 2.0.0-rc5-61424-02 Update Stage0 to use the latest build. Update README with new distros. Back porting #5597 into rel/1.0.0 Fixing the exclude pattern used by the Migration to exclude WEB SDK globs. Remove RID from test package creation Disable migrate and publish web app with content because CI does not have NPM Adding an E2E test for pack with content during migration. Fixing a failing test and adding a few more E2E tests around binplace content for migrated projects. Fix debian_config.json on ubuntu16.10 Updating publish, pack and build of content to use None with Never/false/Never in their metadata for excluded items. Intermediate commit to get a WIP PR out. This adds the None Update with CopyToOutputDirectory set to Never. Switching the CopyToOutput for build and publish and the file for pack to use None Update instead of include. Also, fixed the exclude patterns for web apps. Do not migrate Content that is already included in the Web SDK for web apps. ...
199 lines
8.7 KiB
C#
199 lines
8.7 KiB
C#
using Microsoft.Build.Construction;
|
|
using Microsoft.DotNet.ProjectJsonMigration;
|
|
using Microsoft.DotNet.Internal.ProjectModel;
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
using NuGet.Frameworks;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Xunit;
|
|
using FluentAssertions;
|
|
using Microsoft.DotNet.ProjectJsonMigration.Rules;
|
|
|
|
namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|
{
|
|
public class GivenThatIWantToMigrateTFMs : TestBase
|
|
{
|
|
[Fact(Skip="Emitting this until x-targeting full support is in")]
|
|
public void MigratingNetcoreappProjectDoesNotPopulateTargetFrameworkIdentifierAndTargetFrameworkVersion()
|
|
{
|
|
var testDirectory = Temp.CreateDirectory().Path;
|
|
var testPJ = new ProjectJsonBuilder(TestAssets)
|
|
.FromTestAssetBase("TestAppWithRuntimeOptions")
|
|
.WithCustomProperty("buildOptions", new Dictionary<string, string>
|
|
{
|
|
{ "emitEntryPoint", "false" }
|
|
})
|
|
.SaveToDisk(testDirectory);
|
|
|
|
var projectContext = ProjectContext.Create(testDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
|
|
var mockProj = ProjectRootElement.Create();
|
|
|
|
var migrationSettings = MigrationSettings.CreateMigrationSettingsTestHook(testDirectory, testDirectory, mockProj);
|
|
var migrationInputs = new MigrationRuleInputs(
|
|
new[] { projectContext },
|
|
mockProj,
|
|
mockProj.AddItemGroup(),
|
|
mockProj.AddPropertyGroup());
|
|
|
|
new MigrateTFMRule().Apply(migrationSettings, migrationInputs);
|
|
|
|
mockProj.Properties.Count(p => p.Name == "TargetFrameworkIdentifier").Should().Be(0);
|
|
mockProj.Properties.Count(p => p.Name == "TargetFrameworkVersion").Should().Be(0);
|
|
}
|
|
|
|
[Fact]
|
|
public void MigratingMultiTFMProjectPopulatesTargetFrameworksWithShortTfms()
|
|
{
|
|
var testDirectory = Temp.CreateDirectory().Path;
|
|
var testPJ = new ProjectJsonBuilder(TestAssets)
|
|
.FromTestAssetBase("TestLibraryWithMultipleFrameworks")
|
|
.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 == "TargetFrameworks").Should().Be(1);
|
|
mockProj.Properties.First(p => p.Name == "TargetFrameworks")
|
|
.Value.Should().Be("net20;net35;net40;net461;netstandard1.5");
|
|
}
|
|
|
|
[Fact]
|
|
public void MigratingCoreAndDesktopTFMsDoesNoAddRuntimeIdentifiersOrRuntimeIdentifierWhenTheProjectDoesNothaveAnyAlready()
|
|
{
|
|
var testDirectory = Temp.CreateDirectory().Path;
|
|
var testPJ = new ProjectJsonBuilder(TestAssets)
|
|
.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 == "RuntimeIdentifiers").Should().Be(0);
|
|
mockProj.Properties.Count(p => p.Name == "RuntimeIdentifier").Should().Be(0);
|
|
}
|
|
|
|
[Fact]
|
|
public void MigrateTFMRuleDoesNotAddRuntimesWhenMigratingDesktopTFMsWithRuntimesAlready()
|
|
{
|
|
var testDirectory = Temp.CreateDirectory().Path;
|
|
var testPJ = new ProjectJsonBuilder(TestAssets)
|
|
.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 MigratingProjectWithFullFrameworkTFMsDoesNotAddRuntimeIdentifiersOrRuntimeIdentiferWhenNoRuntimesExistAlready()
|
|
{
|
|
var testDirectory = Temp.CreateDirectory().Path;
|
|
var testPJ = new ProjectJsonBuilder(TestAssets)
|
|
.FromTestAssetBase("AppWith4netTfm0Rid")
|
|
.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);
|
|
mockProj.Properties.Where(p => p.Name == "RuntimeIdentifier").Should().HaveCount(0);
|
|
}
|
|
|
|
[Fact]
|
|
public void MigratingSingleTFMProjectPopulatesTargetFramework()
|
|
{
|
|
var testDirectory = Temp.CreateDirectory().Path;
|
|
var testPJ = new ProjectJsonBuilder(TestAssets)
|
|
.FromTestAssetBase("TestAppWithRuntimeOptions")
|
|
.WithCustomProperty("buildOptions", new Dictionary<string, string>
|
|
{
|
|
{ "emitEntryPoint", "false" }
|
|
})
|
|
.SaveToDisk(testDirectory);
|
|
|
|
var projectContexts = ProjectContext.CreateContextForEachFramework(testDirectory);
|
|
var mockProj = ProjectRootElement.Create();
|
|
|
|
// Run BuildOptionsRule
|
|
var migrationSettings = MigrationSettings.CreateMigrationSettingsTestHook(testDirectory, testDirectory, mockProj);
|
|
var migrationInputs = new MigrationRuleInputs(
|
|
projectContexts,
|
|
mockProj,
|
|
mockProj.AddItemGroup(),
|
|
mockProj.AddPropertyGroup());
|
|
|
|
new MigrateTFMRule().Apply(migrationSettings, migrationInputs);
|
|
Console.WriteLine(mockProj.RawXml);
|
|
|
|
mockProj.Properties.Count(p => p.Name == "TargetFramework").Should().Be(1);
|
|
}
|
|
|
|
[Fact]
|
|
public void MigratingLibWithMultipleTFMsDoesNotAddRuntimes()
|
|
{
|
|
var testDirectory = Temp.CreateDirectory().Path;
|
|
var testPJ = new ProjectJsonBuilder(TestAssets)
|
|
.FromTestAssetBase("PJLibWithMultipleFrameworks")
|
|
.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);
|
|
|
|
var reason = "Should not add runtime identifiers for libraries";
|
|
mockProj.Properties.Count(p => p.Name == "RuntimeIdentifiers").Should().Be(0, reason);
|
|
mockProj.Properties.Count(p => p.Name == "RuntimeIdentifier").Should().Be(0, reason);
|
|
}
|
|
}
|
|
}
|