ProjectJsonMigration Tests

This commit is contained in:
Bryan Thornbury 2016-08-22 12:24:10 -07:00
parent 47cf8fbda6
commit 28e2aa493d
22 changed files with 2118 additions and 0 deletions

View file

@ -0,0 +1,109 @@
using System.Linq;
using FluentAssertions;
using Microsoft.Build.Construction;
using Xunit;
namespace Microsoft.DotNet.ProjectJsonMigration.Tests
{
public class GivenMSBuildExtensions
{
[Fact]
public void Includes_returns_include_value_split_by_semicolon()
{
var project = ProjectRootElement.Create();
var item = project.CreateItemElement("test");
item.Include = "include1;include2;aaa";
var includes = item.Includes().ToArray();
includes[0].Should().Be("include1");
includes[1].Should().Be("include2");
includes[2].Should().Be("aaa");
}
[Fact]
public void Excludes_returns_include_value_split_by_semicolon()
{
var project = ProjectRootElement.Create();
var item = project.CreateItemElement("test");
item.Exclude = "include1;include2;aaa";
var excludes = item.Excludes().ToArray();
excludes[0].Should().Be("include1");
excludes[1].Should().Be("include2");
excludes[2].Should().Be("aaa");
}
[Fact]
public void ItemsWithoutConditions_returns_items_without_a_condition()
{
var project = ProjectRootElement.Create();
var item = project.AddItem("test", "include1");
project.ItemsWithoutConditions().Count().Should().Be(1);
project.ItemsWithoutConditions().First().Should().Be(item);
}
[Fact]
public void ItemsWithoutConditions_doesnt_return_items_with_a_condition()
{
var project = ProjectRootElement.Create();
var conditionlessItems = project.AddItem("test", "include1");
var conditionItem = project.AddItem("test2", "include2");
conditionItem.Condition = "SomeCondition";
project.ItemsWithoutConditions().Count().Should().Be(1);
project.ItemsWithoutConditions().First().Should().Be(conditionlessItems);
}
[Fact]
public void ItemsWithoutConditions_doesnt_return_items_with_a_parent_with_a_condition()
{
var project = ProjectRootElement.Create();
var conditionlessItems = project.AddItem("test", "include1");
var conditionItemGroup = project.AddItemGroup();
conditionItemGroup.Condition = "SomeCondition";
conditionItemGroup.AddItem("test2", "include2");
project.ItemsWithoutConditions().Count().Should().Be(1);
project.ItemsWithoutConditions().First().Should().Be(conditionlessItems);
}
[Fact]
public void AddIncludes_merges_include_sets()
{
var project = ProjectRootElement.Create();
var item1 = project.AddItem("test", "include1;include2");
item1.AddIncludes(new string[] {"include2", "include3"});
item1.Include.Should().Be("include1;include2;include3");
}
[Fact]
public void AddExcludes_merges_include_sets()
{
var project = ProjectRootElement.Create();
var item1 = project.AddItem("test", "include1");
item1.Exclude = "exclude1;exclude2";
item1.AddExcludes(new string[] {"exclude2", "exclude3"});
item1.Exclude.Should().Be("exclude1;exclude2;exclude3");
}
[Fact]
public void AddMetadata_adds_metadata_available_via_Metadata_on_an_item()
{
var project = ProjectRootElement.Create();
var item1 = project.AddItem("test", "include1");
item1.AddMetadata("name", "value");
item1.HasMetadata.Should().BeTrue();
var item2 = project.AddItem("test1", "hey");
item2.AddMetadata(item1.Metadata);
item2.HasMetadata.Should().BeTrue();
item2.Metadata.First().Name.Should().Be("name");
item2.Metadata.First().Value.Should().Be("value");
}
}
}

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0.25123" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25123</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>1F2EF070-AC5F-4078-AFB0-65745AC691B9</ProjectGuid>
<RootNamespace>Microsoft.DotNet.ProjectJsonMigration.Tests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View file

@ -0,0 +1,117 @@
using Microsoft.DotNet.TestFramework;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.DotNet.ProjectJsonMigration.Tests
{
/// <summary>
/// Used to build up test scenario project.jsons without needing to add a new test asset.
/// </summary>
public class ProjectJsonBuilder
{
private static readonly string s_defaultProjectJsonTestAsset = "TestAppWithRuntimeOptions";
private TestAssetsManager _testAssetsManager;
private JObject _projectJson;
private bool _baseDefined = false;
private bool _baseProjectDirectory;
public ProjectJsonBuilder(TestAssetsManager testAssetsManager)
{
_testAssetsManager = testAssetsManager;
}
public string SaveToDisk(string outputDirectory)
{
EnsureBaseIsSet();
var projectPath = Path.Combine(outputDirectory, "project.json");
File.WriteAllText(projectPath, _projectJson.ToString());
return projectPath;
}
public JObject Build()
{
EnsureBaseIsSet();
return _projectJson;
}
public ProjectJsonBuilder FromDefaultBase()
{
return FromTestAssetBase(s_defaultProjectJsonTestAsset);
}
public ProjectJsonBuilder FromTestAssetBase(string testAssetName)
{
var testProjectDirectory = _testAssetsManager.CreateTestInstance(testAssetName).Path;
var testProject = Path.Combine(testProjectDirectory, "project.json");
SetBase(JObject.Parse(File.ReadAllText(testProject)));
return this;
}
public ProjectJsonBuilder FromStringBase(string jsonString)
{
SetBase(JObject.Parse(jsonString));
return this;
}
public ProjectJsonBuilder FromEmptyBase()
{
SetBase(new JObject());
return this;
}
public ProjectJsonBuilder WithCustomProperty(string propertyName, Dictionary<string, string> value)
{
EnsureBaseIsSet();
_projectJson[propertyName] = JObject.FromObject(value);
return this;
}
public ProjectJsonBuilder WithCustomProperty(string propertyName, string value)
{
EnsureBaseIsSet();
_projectJson[propertyName] = value;
return this;
}
public ProjectJsonBuilder WithCustomProperty(string propertyName, string[] value)
{
EnsureBaseIsSet();
_projectJson[propertyName] = JArray.FromObject(value);
return this;
}
private void SetBase(JObject project)
{
if (_baseDefined)
{
throw new Exception("Base was already defined.");
}
_baseDefined = true;
_projectJson = project;
}
private void EnsureBaseIsSet()
{
if (!_baseDefined)
{
throw new Exception("Cannot build without base set");
}
}
}
}

View file

@ -0,0 +1,449 @@
using Microsoft.Build.Construction;
using Microsoft.DotNet.ProjectJsonMigration;
using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.Tools.Test.Utilities;
using NuGet.Frameworks;
using System;
using System.IO;
using System.Linq;
using Xunit;
using FluentAssertions;
using Microsoft.DotNet.ProjectModel.Files;
namespace Microsoft.DotNet.ProjectJsonMigration.Tests
{
public class GivenThatIWantToMigrateBuildOptions : TestBase
{
[Fact]
public void Specified_default_properties_are_removed_when_they_exists_in_the_csproj_template()
{
// Setup project with default properties
var defaultPropertiesExpectedToBeRemoved = new string[]
{
"OutputType",
"TargetExt"
};
var defaultValue = "defaultValue";
var templateProj = ProjectRootElement.Create();
var defaultPropertyGroup = templateProj.AddPropertyGroup();
foreach (var defaultPropertyName in defaultPropertiesExpectedToBeRemoved)
{
defaultPropertyGroup.AddProperty(defaultPropertyName, defaultValue);
}
// Setup projectcontext
var testProjectDirectory = TestAssetsManager.CreateTestInstance("TestAppWithRuntimeOptions").Path;
var projectContext = ProjectContext.Create(testProjectDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
var testSettings = new MigrationSettings(testProjectDirectory, testProjectDirectory, "1.0.0", templateProj);
var testInputs = new MigrationRuleInputs(new[] {projectContext}, templateProj, templateProj.AddItemGroup(),
templateProj.AddPropertyGroup());
new MigrateBuildOptionsRule().Apply(testSettings, testInputs);
defaultPropertyGroup.Properties.Count.Should().Be(0);
}
[Fact]
public void Migrating_empty_buildOptions_populates_only_AssemblyName_and_OutputType()
{
var mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": { }
}");
mockProj.Properties.Count().Should().Be(2);
mockProj.Properties.Any(
p =>
!(p.Name.Equals("AssemblyName", StringComparison.Ordinal) ||
p.Name.Equals("OutputType", StringComparison.Ordinal))).Should().BeFalse();
mockProj.Items.Count().Should().Be(2);
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 == "EmbeddedResource").Include.Should().Be(@"compiler\resources\**\*;**\*.resx");
mockProj.Items.First(i => i.ItemType == "EmbeddedResource").Exclude.Should().Be(@"bin\**;obj\**;**\*.xproj;packages\**");
}
[Fact]
public void Migrating_EmitEntryPoint_true_populates_OutputType_and_TargetExt_fields()
{
var mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""emitEntryPoint"": ""true""
}
}");
mockProj.Properties.Count(p => p.Name == "OutputType").Should().Be(1);
mockProj.Properties.Count(p => p.Name == "TargetExt").Should().Be(1);
mockProj.Properties.First(p => p.Name == "OutputType").Value.Should().Be("Exe");
mockProj.Properties.First(p => p.Name == "TargetExt").Value.Should().Be(".dll");
}
[Fact]
public void Migrating_EmitEntryPoint_false_populates_OutputType_fields()
{
var mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""emitEntryPoint"": ""false""
}
}");
mockProj.Properties.Count(p => p.Name == "OutputType").Should().Be(1);
mockProj.Properties.First(p => p.Name == "OutputType").Value.Should().Be("Library");
}
[Fact]
public void Migrating_define_populates_DefineConstants()
{
var mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""define"": [ ""DEBUG"", ""TRACE"" ]
}
}");
mockProj.Properties.Count(p => p.Name == "DefineConstants").Should().Be(1);
mockProj.Properties.First(p => p.Name == "DefineConstants").Value.Should().Be("DEBUG;TRACE");
}
[Fact]
public void Migrating_nowarn_populates_NoWarn()
{
var mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""nowarn"": [ ""CS0168"", ""CS0219"" ]
}
}");
mockProj.Properties.Count(p => p.Name == "NoWarn").Should().Be(1);
mockProj.Properties.First(p => p.Name == "NoWarn").Value.Should().Be("CS0168;CS0219");
}
[Fact]
public void Migrating_warningsAsErrors_populates_WarningsAsErrors()
{
var mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""warningsAsErrors"": ""true""
}
}");
mockProj.Properties.Count(p => p.Name == "WarningsAsErrors").Should().Be(1);
mockProj.Properties.First(p => p.Name == "WarningsAsErrors").Value.Should().Be("true");
mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""warningsAsErrors"": ""false""
}
}");
mockProj.Properties.Count(p => p.Name == "WarningsAsErrors").Should().Be(0);
}
[Fact]
public void Migrating_allowUnsafe_populates_AllowUnsafeBlocks()
{
var mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""allowUnsafe"": ""true""
}
}");
mockProj.Properties.Count(p => p.Name == "AllowUnsafeBlocks").Should().Be(1);
mockProj.Properties.First(p => p.Name == "AllowUnsafeBlocks").Value.Should().Be("true");
mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""allowUnsafe"": ""false""
}
}");
mockProj.Properties.Count(p => p.Name == "AllowUnsafeBlocks").Should().Be(0);
}
[Fact]
public void Migrating_optimize_populates_Optimize()
{
var mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""optimize"": ""true""
}
}");
mockProj.Properties.Count(p => p.Name == "Optimize").Should().Be(1);
mockProj.Properties.First(p => p.Name == "Optimize").Value.Should().Be("true");
mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""optimize"": ""false""
}
}");
mockProj.Properties.Count(p => p.Name == "Optimize").Should().Be(0);
}
[Fact]
public void Migrating_platform_populates_PlatformTarget()
{
var mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""platform"": ""x64""
}
}");
mockProj.Properties.Count(p => p.Name == "PlatformTarget").Should().Be(1);
mockProj.Properties.First(p => p.Name == "PlatformTarget").Value.Should().Be("x64");
mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""platform"": ""x86""
}
}");
mockProj.Properties.Count(p => p.Name == "PlatformTarget").Should().Be(1);
mockProj.Properties.First(p => p.Name == "PlatformTarget").Value.Should().Be("x86");
mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""platform"": ""foo""
}
}");
mockProj.Properties.Count(p => p.Name == "PlatformTarget").Should().Be(1);
mockProj.Properties.First(p => p.Name == "PlatformTarget").Value.Should().Be("foo");
}
[Fact]
public void Migrating_languageVersion_populates_LangVersion()
{
var mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""languageVersion"": ""5""
}
}");
mockProj.Properties.Count(p => p.Name == "LangVersion").Should().Be(1);
mockProj.Properties.First(p => p.Name == "LangVersion").Value.Should().Be("5");
}
[Fact]
public void Migrating_keyFile_populates_AssemblyOriginatorKeyFile_and_SignAssembly()
{
var mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""keyFile"": ""../keyfile.snk""
}
}");
mockProj.Properties.Count(p => p.Name == "AssemblyOriginatorKeyFile").Should().Be(1);
mockProj.Properties.First(p => p.Name == "AssemblyOriginatorKeyFile").Value.Should().Be("../keyfile.snk");
mockProj.Properties.Count(p => p.Name == "SignAssembly").Should().Be(1);
mockProj.Properties.First(p => p.Name == "SignAssembly").Value.Should().Be("true");
}
[Fact]
public void Migrating_delaySign_populates_DelaySign()
{
var mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""delaySign"": ""true""
}
}");
mockProj.Properties.Count(p => p.Name == "DelaySign").Should().Be(1);
mockProj.Properties.First(p => p.Name == "DelaySign").Value.Should().Be("true");
mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""delaySign"": ""false""
}
}");
mockProj.Properties.Count(p => p.Name == "DelaySign").Should().Be(0);
}
[Fact]
public void Migrating_publicSign_populates_PublicSign()
{
var mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""publicSign"": ""true""
}
}");
mockProj.Properties.Count(p => p.Name == "PublicSign").Should().Be(1);
mockProj.Properties.First(p => p.Name == "PublicSign").Value.Should().Be("true");
mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""publicSign"": ""false""
}
}");
mockProj.Properties.Count(p => p.Name == "PublicSign").Should().Be(0);
}
[Fact]
public void Migrating_debugType_populates_DebugType()
{
var mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""debugType"": ""full""
}
}");
mockProj.Properties.Count(p => p.Name == "DebugType").Should().Be(1);
mockProj.Properties.First(p => p.Name == "DebugType").Value.Should().Be("full");
mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""debugType"": ""foo""
}
}");
mockProj.Properties.Count(p => p.Name == "DebugType").Should().Be(1);
mockProj.Properties.First(p => p.Name == "DebugType").Value.Should().Be("foo");
}
[Fact]
public void Migrating_outputName_populates_AssemblyName()
{
var mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""outputName"": ""ARandomName""
}
}");
mockProj.Properties.Count(p => p.Name == "AssemblyName").Should().Be(1);
mockProj.Properties.First(p => p.Name == "AssemblyName").Value.Should().Be("ARandomName");
}
[Fact]
public void Migrating_xmlDoc_populates_GenerateDocumentationFile()
{
var mockProj = RunBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""xmlDoc"": ""true""
}
}");
mockProj.Properties.Count(p => p.Name == "GenerateDocumentationFile").Should().Be(1);
mockProj.Properties.First(p => p.Name == "GenerateDocumentationFile").Value.Should().Be("true");
}
[Theory]
[InlineData("compile", "Compile")]
[InlineData("embed", "EmbeddedResource")]
[InlineData("copyToOutput", "Content")]
private void Migrating_compile_include_exclude_Populates_compile_item(
string group,
string itemName)
{
var testDirectory = Temp.CreateDirectory().Path;
Directory.CreateDirectory(Path.Combine(testDirectory, "root"));
Directory.CreateDirectory(Path.Combine(testDirectory, "src"));
File.WriteAllText(Path.Combine(testDirectory, "root", "file1.txt"), "content");
File.WriteAllText(Path.Combine(testDirectory, "root", "file2.txt"), "content");
File.WriteAllText(Path.Combine(testDirectory, "root", "file3.txt"), "content");
File.WriteAllText(Path.Combine(testDirectory, "src", "file1.cs"), "content");
File.WriteAllText(Path.Combine(testDirectory, "src", "file2.cs"), "content");
File.WriteAllText(Path.Combine(testDirectory, "src", "file3.cs"), "content");
File.WriteAllText(Path.Combine(testDirectory, "rootfile.cs"), "content");
var pj = @"
{
""buildOptions"": {
""<group>"": {
""include"": [""root"", ""src"", ""rootfile.cs""],
""exclude"": [""src"", ""rootfile.cs""],
""includeFiles"": [""src/file1.cs"", ""src/file2.cs""],
""excludeFiles"": [""src/file2.cs""]
}
}
}".Replace("<group>", group);
var mockProj = RunBuildOptionsRuleOnPj(pj,
testDirectory: testDirectory);
mockProj.Items.Count(i => i.ItemType.Equals(itemName, StringComparison.Ordinal)).Should().Be(2);
var defaultIncludePatterns = group == "compile" ? ProjectFilesCollection.DefaultCompileBuiltInPatterns
: group == "embed" ? ProjectFilesCollection.DefaultResourcesBuiltInPatterns
: Enumerable.Empty<string>();
var defaultExcludePatterns = group == "copyToOutput" ? ProjectFilesCollection.DefaultPublishExcludePatterns
: ProjectFilesCollection.DefaultBuiltInExcludePatterns;
foreach (var item in mockProj.Items.Where(i => i.ItemType.Equals(itemName, StringComparison.Ordinal)))
{
if (item.Include.Contains(@"src\file1.cs"))
{
item.Include.Should().Be(@"src\file1.cs;src\file2.cs");
item.Exclude.Should().Be(@"src\file2.cs");
}
else
{
if (defaultIncludePatterns.Any())
{
item.Include.Should()
.Be(@"root\**\*;src\**\*;rootfile.cs;" + string.Join(";", defaultIncludePatterns).Replace("/", "\\"));
}
else
{
item.Include.Should()
.Be(@"root\**\*;src\**\*;rootfile.cs");
}
if (defaultExcludePatterns.Any())
{
item.Exclude.Should()
.Be(@"src\**\*;rootfile.cs;" + string.Join(";", defaultExcludePatterns).Replace("/", "\\") +
@";src\file2.cs");
}
else
{
item.Exclude.Should()
.Be(@"src\**\*;rootfile.cs;src\file2.cs");
}
}
}
}
private ProjectRootElement RunBuildOptionsRuleOnPj(string s, string testDirectory = null)
{
testDirectory = testDirectory ?? Temp.CreateDirectory().Path;
return TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
{
new MigrateBuildOptionsRule()
}, s, testDirectory);
}
}
}

View file

@ -0,0 +1,162 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Build.Construction;
using Microsoft.DotNet.Migration.Tests;
using Microsoft.DotNet.ProjectJsonMigration;
using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.Tools.Test.Utilities;
using NuGet.Frameworks;
using Xunit;
using FluentAssertions;
using Microsoft.DotNet.ProjectJsonMigration.Tests;
namespace Microsoft.DotNet.ProjectJsonMigrationMigration.Tests
{
public class GivenThatIWantToMigrateConfigurations : TestBase
{
[Fact]
public void Configuration_buildOptions_produce_expected_properties_in_a_group_with_a_condition()
{
var mockProj = RunConfigurationsRuleOnPj(@"
{
""configurations"": {
""testconfig"": {
""buildOptions"": {
""emitEntryPoint"": ""true"",
""debugType"": ""full""
}
}
}
}");
mockProj.Properties.Count(
prop => prop.Name == "OutputType" || prop.Name == "TargetExt" || prop.Name == "DebugType").Should().Be(3);
mockProj.Properties.First(p => p.Name == "OutputType")
.Parent.Condition.Should()
.Contain("'$(Configuration)' == 'testconfig'");
}
[Fact]
public void Configuration_buildOptions_properties_are_not_written_when_they_overlap_with_buildOptions()
{
var mockProj = RunConfigurationsAndBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""emitEntryPoint"": ""true"",
""debugType"": ""full""
},
""configurations"": {
""testconfig"": {
""buildOptions"": {
""emitEntryPoint"": ""true"",
""debugType"": ""full""
}
}
}
}");
mockProj.Properties.Count(property =>
property.Name == "OutputType" || property.Name == "TargetExt" || property.Name == "DebugType")
.Should().Be(3);
foreach (var property in mockProj.Properties.Where(property =>
property.Name == "OutputType" || property.Name == "TargetExt" || property.Name == "DebugType"))
{
property.Parent.Condition.Should().Be(string.Empty);
}
}
[Fact]
public void Configuration_buildOptions_includes_are_not_written_when_they_overlap_with_buildOptions()
{
var mockProj = RunConfigurationsAndBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""copyToOutput"": {
""include"": [""src""],
""exclude"": [""src"", ""rootfile.cs""],
""includeFiles"": [""src/file1.cs"", ""src/file2.cs""],
""excludeFiles"": [""src/file2.cs""]
}
},
""configurations"": {
""testconfig"": {
""buildOptions"": {
""copyToOutput"": {
""include"": [""root"", ""src"", ""rootfile.cs""],
""exclude"": [""src"", ""rootfile.cs""],
""includeFiles"": [""src/file1.cs"", ""src/file2.cs""],
""excludeFiles"": [""src/file2.cs""]
}
}
}
}
}");
mockProj.Items.Count(item => item.ItemType == "Content").Should().Be(3);
mockProj.Items.Where(item => item.ItemType == "Content")
.Count(item => !string.IsNullOrEmpty(item.Parent.Condition))
.Should()
.Be(1);
var configContent = mockProj.Items
.Where(item => item.ItemType == "Content").First(item => !string.IsNullOrEmpty(item.Parent.Condition));
// Directories are not converted to globs in the result because we did not write the directory
configContent.Include.Should().Be(@"root;rootfile.cs");
configContent.Exclude.Should().Be(@"src;rootfile.cs;src\file2.cs");
}
[Fact]
public void Configuration_buildOptions_includes_which_have_different_excludes_than_buildOptions_throws()
{
Action action = () => RunConfigurationsRuleOnPj(@"
{
""buildOptions"": {
""copyToOutput"": {
""include"": [""src""],
""exclude"": [""rootfile.cs""],
""includeFiles"": [""src/file1.cs"", ""src/file2.cs""],
""excludeFiles"": [""src/file3.cs""]
}
},
""configurations"": {
""testconfig"": {
""buildOptions"": {
""copyToOutput"": {
""include"": [""root"", ""src"", ""rootfile.cs""],
""exclude"": [""src"", ""rootfile.cs""],
""includeFiles"": [""src/file1.cs"", ""src/file2.cs""],
""excludeFiles"": [""src/file2.cs""]
}
}
}
}
}");
action.ShouldThrow<Exception>()
.WithMessage(
"Unable to migrate projects with excluded files in configurations.");
}
private ProjectRootElement RunConfigurationsRuleOnPj(string s, string testDirectory = null)
{
testDirectory = testDirectory ?? Temp.CreateDirectory().Path;
return TemporaryProjectFileRuleRunner.RunRules(new[] {new MigrateConfigurationsRule()}, s, testDirectory);
}
private ProjectRootElement RunConfigurationsAndBuildOptionsRuleOnPj(string s, string testDirectory = null)
{
testDirectory = testDirectory ?? Temp.CreateDirectory().Path;
return TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
{
new MigrateBuildOptionsRule(),
new MigrateConfigurationsRule()
}, s, testDirectory);
}
}
}

View file

@ -0,0 +1,85 @@
using Microsoft.Build.Construction;
using Microsoft.DotNet.ProjectJsonMigration;
using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.Tools.Test.Utilities;
using NuGet.Frameworks;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
using FluentAssertions;
namespace Microsoft.DotNet.Migration.Tests
{
public class GivenThatIWantToMigrateProjectDependencies : TestBase
{
// Workaround For P2P dependencies
// ISSUE: https://github.com/dotnet/sdk/issues/73
[Fact]
public void If_a_project_dependency_is_present_DesignTimeAutoUnify_and_AutoUnify_are_present()
{
var solutionDirectory =
TestAssetsManager.CreateTestInstance("TestAppWithLibrary", callingMethod: "p").WithLockFiles().Path;
var appDirectory = Path.Combine(solutionDirectory, "TestApp");
var libDirectory = Path.Combine(solutionDirectory, "TestLibrary");
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
var mockProj = ProjectRootElement.Create();
var testSettings = new MigrationSettings(appDirectory, appDirectory, "1.0.0", mockProj);
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(),
mockProj.AddPropertyGroup());
new MigrateProjectDependenciesRule().Apply(testSettings, testInputs);
var autoUnify = mockProj.Properties.Where(p => p.Name == "AutoUnify");
autoUnify.Count().Should().Be(1);
autoUnify.First().Value.Should().Be("true");
var designTimeAutoUnify = mockProj.Properties.Where(p => p.Name == "DesignTimeAutoUnify");
designTimeAutoUnify.Count().Should().Be(1);
designTimeAutoUnify.First().Value.Should().Be("true");
}
[Fact]
public void Project_dependencies_are_migrated_to_ProjectReference()
{
var solutionDirectory =
TestAssetsManager.CreateTestInstance("TestAppWithLibrary", callingMethod: "p").WithLockFiles().Path;
var appDirectory = Path.Combine(solutionDirectory, "TestApp");
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
var mockProj = ProjectRootElement.Create();
var testSettings = new MigrationSettings(appDirectory, appDirectory, "1.0.0", mockProj);
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(),
mockProj.AddPropertyGroup());
new MigrateProjectDependenciesRule().Apply(testSettings, testInputs);
var projectReferences = mockProj.Items.Where(item => item.ItemType.Equals("ProjectReference", StringComparison.Ordinal));
projectReferences.Count().Should().Be(1);
projectReferences.First().Include.Should().Be("../TestLibrary/TestLibrary.csproj");
}
[Fact]
public void It_throws_when_project_dependency_is_unresolved()
{
// No Lock file => unresolved
var solutionDirectory =
TestAssetsManager.CreateTestInstance("TestAppWithLibrary").Path;
var appDirectory = Path.Combine(solutionDirectory, "TestApp");
var projectContext = ProjectContext.Create(appDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
var mockProj = ProjectRootElement.Create();
var testSettings = new MigrationSettings(appDirectory, appDirectory, "1.0.0", mockProj);
var testInputs = new MigrationRuleInputs(new[] {projectContext}, mockProj, mockProj.AddItemGroup(), mockProj.AddPropertyGroup());
Action action = () => new MigrateProjectDependenciesRule().Apply(testSettings, testInputs);
action.ShouldThrow<Exception>()
.WithMessage("Cannot migrate unresolved project dependency, please ensure restore has been run.");
}
}
}

View file

@ -0,0 +1,149 @@
using System;
using System.IO;
using System.Linq;
using Microsoft.Build.Construction;
using Microsoft.DotNet.Migration.Tests;
using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.ProjectModel.Files;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities;
using NuGet.Frameworks;
using Xunit;
using FluentAssertions;
namespace Microsoft.DotNet.ProjectJsonMigration.Tests
{
public class GivenThatIWantToMigratePublishOptions : TestBase
{
[Fact]
private void Migrating_publishOptions_include_exclude_populates_Content_item()
{
var testDirectory = Temp.CreateDirectory().Path;
WriteFilesInProjectDirectory(testDirectory);
var mockProj = RunPublishOptionsRuleOnPj(@"
{
""publishOptions"": {
""include"": [""root"", ""src"", ""rootfile.cs""],
""exclude"": [""src"", ""rootfile.cs""],
""includeFiles"": [""src/file1.cs"", ""src/file2.cs""],
""excludeFiles"": [""src/file2.cs""]
}
}",
testDirectory: testDirectory);
mockProj.Items.Count(i => i.ItemType.Equals("Content", StringComparison.Ordinal)).Should().Be(2);
// From ProjectReader #L725 (Both are empty)
var defaultIncludePatterns = Enumerable.Empty<string>();
var defaultExcludePatterns = ProjectFilesCollection.DefaultPublishExcludePatterns;
foreach (var item in mockProj.Items.Where(i => i.ItemType.Equals("Content", StringComparison.Ordinal)))
{
if (item.Include.Contains(@"src\file1.cs"))
{
item.Include.Should().Be(@"src\file1.cs;src\file2.cs");
item.Exclude.Should().Be(@"src\file2.cs");
}
else
{
item.Include.Should()
.Be(@"root\**\*;src\**\*;rootfile.cs");
item.Exclude.Should()
.Be(@"src\**\*;rootfile.cs;src\file2.cs");
}
}
}
[Fact]
private void Migrating_publishOptions_and_buildOptions_CopyToOutput_merges_Content_items()
{
var testDirectory = Temp.CreateDirectory().Path;
WriteFilesInProjectDirectory(testDirectory);
var mockProj = RunPublishAndBuildOptionsRuleOnPj(@"
{
""buildOptions"": {
""copyToOutput"": {
""include"": [""src"", ""rootfile.cs""],
""exclude"": [""src"", ""rootfile.cs""],
""includeFiles"": [""src/file1.cs"", ""src/file2.cs""],
""excludeFiles"": [""src/file2.cs""]
}
},
""publishOptions"": {
""include"": [""root"", ""src"", ""rootfile.cs""],
""exclude"": [""src"", ""rootfile.cs""],
""includeFiles"": [""src/file1.cs"", ""src/file2.cs""],
""excludeFiles"": [""src/file3.cs""]
}
}",
testDirectory: testDirectory);
Console.WriteLine(string.Join(";", mockProj.Items.Select(i => " ;; " + i.ItemType)));
Console.WriteLine(string.Join(";", mockProj.Items.Select(i => " ;; " + i.Include)));
Console.WriteLine(string.Join(";", mockProj.Items.Select(i => " ;; " + i.Exclude)));
mockProj.Items.Count(i => i.ItemType.Equals("Content", StringComparison.Ordinal)).Should().Be(3);
// From ProjectReader #L725 (Both are empty)
var defaultIncludePatterns = Enumerable.Empty<string>();
var defaultExcludePatterns = ProjectFilesCollection.DefaultPublishExcludePatterns;
foreach (var item in mockProj.Items.Where(i => i.ItemType.Equals("Content", StringComparison.Ordinal)))
{
if (item.Include.Contains(@"root\**\*"))
{
item.Include.Should().Be(@"root\**\*");
item.Exclude.Should().Be(@"src\**\*;rootfile.cs;src\file3.cs");
}
else if (item.Include.Contains(@"src\file1.cs"))
{
item.Include.Should().Be(@"src\file1.cs;src\file2.cs");
item.Exclude.Should().Be(@"src\file2.cs;src\file3.cs");
}
else
{
item.Include.Should()
.Be(@"src\**\*;rootfile.cs");
item.Exclude.Should()
.Be(@"src\**\*;rootfile.cs;src\file2.cs;src\file3.cs");
}
}
}
private void WriteFilesInProjectDirectory(string testDirectory)
{
Directory.CreateDirectory(Path.Combine(testDirectory, "root"));
Directory.CreateDirectory(Path.Combine(testDirectory, "src"));
File.WriteAllText(Path.Combine(testDirectory, "root", "file1.txt"), "content");
File.WriteAllText(Path.Combine(testDirectory, "root", "file2.txt"), "content");
File.WriteAllText(Path.Combine(testDirectory, "root", "file3.txt"), "content");
File.WriteAllText(Path.Combine(testDirectory, "src", "file1.cs"), "content");
File.WriteAllText(Path.Combine(testDirectory, "src", "file2.cs"), "content");
File.WriteAllText(Path.Combine(testDirectory, "src", "file3.cs"), "content");
File.WriteAllText(Path.Combine(testDirectory, "rootfile.cs"), "content");
}
private ProjectRootElement RunPublishOptionsRuleOnPj(string s, string testDirectory = null)
{
testDirectory = testDirectory ?? Temp.CreateDirectory().Path;
return TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
{
new MigratePublishOptionsRule()
}, s, testDirectory);
}
private ProjectRootElement RunPublishAndBuildOptionsRuleOnPj(string s, string testDirectory = null)
{
testDirectory = testDirectory ?? Temp.CreateDirectory().Path;
return TemporaryProjectFileRuleRunner.RunRules(new IMigrationRule[]
{
new MigrateBuildOptionsRule(),
new MigratePublishOptionsRule()
}, s, testDirectory);
}
}
}

View file

@ -0,0 +1,66 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Linq;
using FluentAssertions;
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
using Microsoft.DotNet.ProjectJsonMigration;
using System;
using System.IO;
using Microsoft.Build.Construction;
using Microsoft.DotNet.ProjectModel;
using NuGet.Frameworks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
namespace Microsoft.DotNet.ProjectJsonMigration.Tests
{
public class GivenThatIWantToMigrateRuntimeOptions : TestBase
{
private static readonly string s_runtimeConfigFileName = "runtimeconfig.template.json";
[Fact]
public void RuntimeOptions_are_copied_from_projectJson_to_runtimeconfig_template_json_file()
{
var testInstance = TestAssetsManager.CreateTestInstance("TestAppWithRuntimeOptions").WithLockFiles();
var projectDir = testInstance.Path;
var projectPath = Path.Combine(testInstance.Path, "project.json");
var project = JObject.Parse(File.ReadAllText(projectPath));
var rawRuntimeOptions = (JObject)project.GetValue("runtimeOptions");
var projectContext = ProjectContext.Create(projectDir, FrameworkConstants.CommonFrameworks.NetCoreApp10);
var testSettings = new MigrationSettings(projectDir, projectDir, "1.0.0", default(ProjectRootElement));
var testInputs = new MigrationRuleInputs(new[] { projectContext }, null, null, null);
new MigrateRuntimeOptionsRule().Apply(testSettings, testInputs);
var migratedRuntimeOptionsPath = Path.Combine(projectDir, s_runtimeConfigFileName);
File.Exists(migratedRuntimeOptionsPath).Should().BeTrue();
Console.WriteLine(migratedRuntimeOptionsPath);
var migratedRuntimeOptionsContent = JObject.Parse(File.ReadAllText(migratedRuntimeOptionsPath));
JToken.DeepEquals(rawRuntimeOptions, migratedRuntimeOptionsContent).Should().BeTrue();
}
[Fact]
public void Migrating_ProjectJson_with_no_RuntimeOptions_produces_no_runtimeconfig_template_json_file()
{
var testInstance = TestAssetsManager.CreateTestInstance("TestAppSimple").WithLockFiles();
var projectDir = testInstance.Path;
var projectContext = ProjectContext.Create(projectDir, FrameworkConstants.CommonFrameworks.NetCoreApp10);
var testSettings = new MigrationSettings(projectDir, projectDir, "1.0.0", default(ProjectRootElement));
var testInputs = new MigrationRuleInputs(new[] { projectContext }, null, null, null);
new MigrateRuntimeOptionsRule().Apply(testSettings, testInputs);
var migratedRuntimeOptionsPath = Path.Combine(projectDir, s_runtimeConfigFileName);
File.Exists(migratedRuntimeOptionsPath).Should().BeFalse();
}
}
}

View file

@ -0,0 +1,205 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Linq;
using FluentAssertions;
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
using Microsoft.DotNet.ProjectJsonMigration;
using System;
using System.IO;
using Microsoft.Build.Construction;
namespace Microsoft.DotNet.ProjectJsonMigration.Tests
{
public class GivenThatIWantToMigrateScripts : TestBase
{
[Theory]
[InlineData("compile:FullTargetFramework", "$(TargetFrameworkIdentifier)=$(TargetFrameworkVersion)")]
[InlineData("compile:Configuration", "$(Configuration)")]
[InlineData("compile:OutputFile", "$(TargetPath)")]
[InlineData("compile:OutputDir", "$(TargetDir)")]
[InlineData("publish:ProjectPath", "$(MSBuildThisFileDirectory)")]
[InlineData("publish:Configuration", "$(Configuration)")]
[InlineData("publish:OutputPath", "$(TargetDir)")]
[InlineData("publish:FullTargetFramework", "$(TargetFrameworkIdentifier)=$(TargetFrameworkVersion)")]
[InlineData("project:Version", "$(Version)")]
[InlineData("project:Name", "$(MSBuildThisFileName)")]
[InlineData("project:Directory", "$(MSBuildProjectDirectory)")]
public void Formatting_script_commands_replaces_variables_with_the_right_msbuild_properties(
string variable,
string msbuildReplacement)
{
var scriptMigrationRule = new MigrateScriptsRule();
scriptMigrationRule.ReplaceScriptVariables($"%{variable}%").Should().Be(msbuildReplacement);
}
[Theory]
[InlineData("compile:TargetFramework")]
[InlineData("compile:ResponseFile")]
[InlineData("compile:CompilerExitCode")]
[InlineData("compile:RuntimeOutputDir")]
[InlineData("compile:RuntimeIdentifier")]
[InlineData("publish:TargetFramework")]
[InlineData("publish:Runtime")]
public void Formatting_script_commands_throws_when_variable_is_unsupported(string unsupportedVariable)
{
var scriptMigrationRule = new MigrateScriptsRule();
Action formatScriptAction = () => scriptMigrationRule.ReplaceScriptVariables($"%{unsupportedVariable}%");
formatScriptAction.ShouldThrow<Exception>()
.Where(exc => exc.Message.Contains("is currently an unsupported script variable for project migration"));
}
[Theory]
[InlineData("precompile", "Build")]
[InlineData("prepublish", "Publish")]
public void Migrating_pre_scripts_populates_BeforeTargets_with_appropriate_target(string scriptName, string targetName)
{
var scriptMigrationRule = new MigrateScriptsRule();
ProjectRootElement mockProj = ProjectRootElement.Create();
var commands = new string[] { "fakecommand" };
var target = scriptMigrationRule.MigrateScriptSet(mockProj, mockProj.AddPropertyGroup(), commands, scriptName);
target.BeforeTargets.Should().Be(targetName);
}
[Theory]
[InlineData("postcompile", "Build")]
[InlineData("postpublish", "Publish")]
public void Migrating_post_scripts_populates_AfterTargets_with_appropriate_target(string scriptName, string targetName)
{
var scriptMigrationRule = new MigrateScriptsRule();
ProjectRootElement mockProj = ProjectRootElement.Create();
var commands = new string[] { "fakecommand" };
var target = scriptMigrationRule.MigrateScriptSet(mockProj, mockProj.AddPropertyGroup(), commands, scriptName);
target.AfterTargets.Should().Be(targetName);
}
[Theory]
[InlineData("precompile")]
[InlineData("postcompile")]
[InlineData("prepublish")]
[InlineData("postpublish")]
public void Migrating_scripts_with_multiple_commands_creates_Exec_task_for_each(string scriptName)
{
var scriptMigrationRule = new MigrateScriptsRule();
ProjectRootElement mockProj = ProjectRootElement.Create();
var commands = new string[] { "fakecommand1", "fakecommand2", "mockcommand3" };
var commandsInTask = commands.ToDictionary(c => c, c => false);
var target = scriptMigrationRule.MigrateScriptSet(mockProj, mockProj.AddPropertyGroup(), commands, scriptName);
foreach (var task in target.Tasks)
{
var taskCommand = task.GetParameter("Command");
var originalCommandCandidates = commands.Where(c => taskCommand.Contains(c));
originalCommandCandidates.Count().Should().Be(1);
var command = originalCommandCandidates.First();
commandsInTask[command].Should().Be(false, "Expected to find each element from commands Array once");
commandsInTask[command] = true;
}
commandsInTask.All(commandInTask => commandInTask.Value)
.Should()
.BeTrue("Expected each element from commands array to be found in a task");
}
[Theory]
[InlineData("precompile")]
[InlineData("postcompile")]
[InlineData("prepublish")]
[InlineData("postpublish")]
public void Migrated_ScriptSet_has_Exec_and_replaces_variables(string scriptName)
{
var scriptMigrationRule = new MigrateScriptsRule();
ProjectRootElement mockProj = ProjectRootElement.Create();
var commands = new string[] { "compile:FullTargetFramework", "compile:Configuration"};
var target = scriptMigrationRule.MigrateScriptSet(mockProj, mockProj.AddPropertyGroup(), commands, scriptName);
target.Tasks.Count().Should().Be(commands.Length);
foreach (var task in target.Tasks)
{
var taskCommand = task.GetParameter("Command");
var commandIndex = Array.IndexOf(commands, taskCommand);
commandIndex.Should().Be(-1, "Expected command array elements to be replaced by appropriate msbuild properties");
}
}
[Theory]
[InlineData("precompile")]
[InlineData("postcompile")]
[InlineData("prepublish")]
[InlineData("postpublish")]
public void Migrated_ScriptSet_has_two_MigratedScriptExtensionProperties_for_each_script(string scriptName)
{
var scriptMigrationRule = new MigrateScriptsRule();
ProjectRootElement mockProj = ProjectRootElement.Create();
var commands = new string[] {"compile:FullTargetFramework", "compile:Configuration"};
var propertyGroup = mockProj.AddPropertyGroup();
var target = scriptMigrationRule.MigrateScriptSet(mockProj, propertyGroup, commands,
scriptName);
Console.WriteLine(string.Join(";", propertyGroup.Properties.Select(n => n.Name)));
propertyGroup.Properties.Count().Should().Be(commands.Length * 2);
var count = 0;
foreach (var command in commands)
{
count += 1;
var scriptExtensionProperties =
propertyGroup.Properties.Where(p => p.Name.Contains($"MigratedScriptExtension_{count}")).ToArray();
scriptExtensionProperties.All(p => p.Value == ".sh" || p.Value == ".cmd").Should().BeTrue();
scriptExtensionProperties.Count().Should().Be(2);
}
}
[Theory]
[InlineData("echo", ".\\echo$(MigratedScriptExtension_1)")]
[InlineData("echo hello world", ".\\echo$(MigratedScriptExtension_1) hello world")]
[InlineData("\"echo\"", ".\\\"echo$(MigratedScriptExtension_1)\"")]
[InlineData("\"echo space\"", ".\\\"echo space$(MigratedScriptExtension_1)\"")]
[InlineData("\"echo space\" other args", ".\\\"echo space$(MigratedScriptExtension_1)\" other args")]
[InlineData("\"echo space\" \"other space\"", ".\\\"echo space$(MigratedScriptExtension_1)\" \"other space\"")]
public void Migrated_ScriptSet_has_ScriptExtension_added_to_script_command(string scriptCommandline, string expectedOutputCommand)
{
var scriptMigrationRule = new MigrateScriptsRule();
ProjectRootElement mockProj = ProjectRootElement.Create();
var formattedCommand = scriptMigrationRule.AddScriptExtensionPropertyToCommandLine(scriptCommandline,
"MigratedScriptExtension_1");
formattedCommand.Should().Be(expectedOutputCommand);
}
[Theory]
[InlineData("echo", @".\echo")]
[InlineData("/usr/echo", "/usr/echo")]
[InlineData(@"C:\usr\echo", @"C:\usr\echo")]
[InlineData("\"echo\"", @".\""echo")]
[InlineData("\"/usr/echo\"", @"""/usr/echo")]
[InlineData(@"""C:\usr\echo", @"""C:\usr\echo")]
public void Migrated_ScriptSet_has_dotSlash_prepended_when_command_is_not_rooted(string scriptCommandline,
string expectedOutputCommandPrefix)
{
var scriptMigrationRule = new MigrateScriptsRule();
ProjectRootElement mockProj = ProjectRootElement.Create();
var formattedCommand = scriptMigrationRule.FormatScriptCommand(scriptCommandline,
"MigratedScriptExtension_1");
formattedCommand.Should().StartWith(expectedOutputCommandPrefix);
}
}
}

View file

@ -0,0 +1,43 @@
using Microsoft.Build.Construction;
using Microsoft.DotNet.ProjectJsonMigration;
using Microsoft.DotNet.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;
namespace Microsoft.DotNet.ProjectJsonMigration.Tests
{
public class GivenThatIWantToMigrateProjectFramework : TestBase
{
[Fact]
public void Migrating_netcoreapp_project_Populates_TargetFrameworkIdentifier_and_TargetFrameworkVersion()
{
var testDirectory = Temp.CreateDirectory().Path;
var testPJ = new ProjectJsonBuilder(TestAssetsManager)
.FromDefaultBase()
.WithCustomProperty("buildOptions", new Dictionary<string, string>
{
{ "emitEntryPoint", "false" }
})
.SaveToDisk(testDirectory);
var projectContext = ProjectContext.Create(testDirectory, FrameworkConstants.CommonFrameworks.NetCoreApp10);
var mockProj = ProjectRootElement.Create();
// Run BuildOptionsRule
var testSettings = new MigrationSettings(testDirectory, testDirectory, "1.0.0", mockProj);
var testInputs = new MigrationRuleInputs(new[] { projectContext }, mockProj, mockProj.AddItemGroup(), mockProj.AddPropertyGroup());
new MigrateTFMRule().Apply(testSettings, testInputs);
mockProj.Properties.Count(p => p.Name == "TargetFrameworkIdentifier").Should().Be(1);
mockProj.Properties.Count(p => p.Name == "TargetFrameworkVersion").Should().Be(1);
mockProj.Properties.First(p => p.Name == "TargetFrameworkIdentifier").Value.Should().Be(".NETCoreApp");
mockProj.Properties.First(p => p.Name == "TargetFrameworkVersion").Value.Should().Be("v1.0");
}
}
}

View file

@ -0,0 +1,212 @@
using Microsoft.Build.Construction;
using Microsoft.DotNet.ProjectJsonMigration;
using Microsoft.DotNet.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 System.IO;
using Microsoft.DotNet.Tools.Common;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Utils;
using Build3Command = Microsoft.DotNet.Tools.Test.Utilities.Build3Command;
using TemporaryDotnetNewTemplateProject = Microsoft.DotNet.Cli.TemporaryDotnetNewTemplateProject;
namespace Microsoft.DotNet.Migration.Tests
{
public class GivenThatIWantToMigrateTestApps : TestBase
{
private class Failure
{
public string Phase {get; set;}
public string Message {get; set;}
public string ProjectJson {get; set;}
}
[Theory]
// TODO: Standalone apps [InlineData("TestAppSimple", false)]
// https://github.com/dotnet/sdk/issues/73 [InlineData("TestAppWithLibrary/TestApp", false)]
[InlineData("TestAppWithRuntimeOptions", false)]
public void It_migrates_a_project(string projectName, bool isLibrary)
{
var projectDirectory = TestAssetsManager.CreateTestInstance(projectName, callingMethod: "i").WithLockFiles().Path;
BuildProjectJson(projectDirectory);
var projectJsonBuildOutputs = new HashSet<string>(CollectBuildOutputs(projectDirectory));
CleanBinObj(projectDirectory);
MigrateProject(projectDirectory);
Restore(projectDirectory);
BuildMSBuild(projectDirectory);
var msbuildBuildOutputs = new HashSet<string>(CollectBuildOutputs(projectDirectory));
var outputsIdentical = projectJsonBuildOutputs.SetEquals(msbuildBuildOutputs);
// diagnostics
if (!outputsIdentical)
{
Console.WriteLine("Project.json Outputs:");
Console.WriteLine(string.Join("\n", projectJsonBuildOutputs));
Console.WriteLine("");
Console.WriteLine("MSBuild Outputs:");
Console.WriteLine(string.Join("\n", msbuildBuildOutputs));
}
outputsIdentical.Should().BeTrue();
if (!isLibrary)
{
VerifyMSBuildOutputRunnable(projectDirectory);
}
}
[Theory]
[InlineData("TestAppWithLibrary/TestLibrary")]
[InlineData("TestLibraryWithAnalyzer")]
[InlineData("TestLibraryWithConfiguration")]
public void It_migrates_a_library(string projectName)
{
var projectDirectory =
TestAssetsManager.CreateTestInstance(projectName, callingMethod: "i").WithLockFiles().Path;
BuildProjectJson(projectDirectory);
var projectJsonBuildOutputs = new HashSet<string>(CollectBuildOutputs(projectDirectory));
CleanBinObj(projectDirectory);
MigrateProject(projectDirectory);
Restore(projectDirectory);
BuildMSBuild(projectDirectory);
var msbuildBuildOutputs = new HashSet<string>(CollectBuildOutputs(projectDirectory));
var msBuildHasAdditionalOutputsButIncludesProjectJsonOutputs = projectJsonBuildOutputs.IsProperSubsetOf(msbuildBuildOutputs);
// diagnostics
if (!msBuildHasAdditionalOutputsButIncludesProjectJsonOutputs)
{
Console.WriteLine("Project.json Outputs:");
Console.WriteLine(string.Join("\n", projectJsonBuildOutputs));
Console.WriteLine("");
Console.WriteLine("MSBuild Outputs:");
Console.WriteLine(string.Join("\n", msbuildBuildOutputs));
}
msBuildHasAdditionalOutputsButIncludesProjectJsonOutputs.Should().BeTrue();
}
[Fact]
public void It_migrates_an_app_with_scripts_and_the_scripts_run()
{
var projectDirectory =
TestAssetsManager.CreateTestInstance("TestAppWithMigrateAbleScripts", callingMethod: "i").WithLockFiles().Path;
BuildProjectJson(projectDirectory);
var projectJsonBuildOutputs = new HashSet<string>(CollectBuildOutputs(projectDirectory));
CleanBinObj(projectDirectory);
MigrateProject(projectDirectory);
Restore(projectDirectory);
var msBuildStdOut = BuildMSBuild(projectDirectory);
var msbuildBuildOutputs = new HashSet<string>(CollectBuildOutputs(projectDirectory));
var outputsIdentical = projectJsonBuildOutputs.SetEquals(msbuildBuildOutputs);
outputsIdentical.Should().BeTrue();
VerifyMSBuildOutputRunnable(projectDirectory);
var outputDir =
PathUtility.EnsureTrailingSlash(Path.Combine(projectDirectory, "bin", "Debug", "netcoreapp1.0"));
msBuildStdOut.Should().Contain($"precompile_output ?Debug? ?{outputDir}? ?.NETCoreApp=v1.0?");
msBuildStdOut.Should().Contain($"postcompile_output ?Debug? ?{outputDir}? ?.NETCoreApp=v1.0?");
}
private string RunNetcoreappMSBuildOutput(string projectDirectory)
{
var dllFileName = Path.GetFileName(projectDirectory) + ".dll";
var runnableDll = Path.Combine(projectDirectory, "bin","Debug", "netcoreapp1.0", dllFileName);
var result = new TestCommand("dotnet").ExecuteWithCapturedOutput(runnableDll);
result.Should().Pass();
return result.StdOut;
}
private void VerifyMSBuildOutputRunnable(string projectDirectory)
{
var dllFileName = Path.GetFileName(projectDirectory) + ".dll";
var runnableDlls = Directory.EnumerateFiles(Path.Combine(projectDirectory, "bin"), dllFileName,
SearchOption.AllDirectories);
foreach (var dll in runnableDlls)
{
new TestCommand("dotnet").ExecuteWithCapturedOutput(dll).Should().Pass();
}
}
private IEnumerable<string> CollectBuildOutputs(string projectDirectory)
{
var fullBinPath = Path.GetFullPath(Path.Combine(projectDirectory, "bin"));
return Directory.EnumerateFiles(fullBinPath, "*", SearchOption.AllDirectories)
.Select(p => Path.GetFullPath(p).Substring(fullBinPath.Length));
}
private void CleanBinObj(string projectDirectory)
{
var dirs = new string[] { Path.Combine(projectDirectory, "bin"), Path.Combine(projectDirectory, "obj") };
foreach (var dir in dirs)
{
Directory.Delete(dir, true);
}
}
private void BuildProjectJson(string projectDirectory)
{
var projectFile = Path.Combine(projectDirectory, "project.json");
var result = new BuildCommand(projectPath: projectFile)
.ExecuteWithCapturedOutput();
result.Should().Pass();
}
private void MigrateProject(string projectDirectory)
{
var dotnetNew = new TemporaryDotnetNewTemplateProject();
var sdkVersion = new ProjectJsonParser(dotnetNew.ProjectJson).SdkPackageVersion;
var migrationSettings = new MigrationSettings(projectDirectory, projectDirectory, sdkVersion, dotnetNew.MSBuildProject);
new ProjectMigrator().Migrate(migrationSettings);
}
private void Restore(string projectDirectory)
{
new TestCommand("dotnet")
.WithWorkingDirectory(projectDirectory)
.Execute("restore")
.Should()
.Pass();
}
private string BuildMSBuild(string projectDirectory)
{
var result = new Build3Command()
.WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput();
result
.Should()
.Pass();
return result.StdOut;
}
}
}

View file

@ -0,0 +1,43 @@
using System.Collections.Generic;
using Microsoft.Build.Construction;
using Microsoft.DotNet.ProjectModel;
using NuGet.Frameworks;
namespace Microsoft.DotNet.ProjectJsonMigration.Tests
{
public class TemporaryProjectFileRuleRunner
{
public static ProjectRootElement RunRules(IEnumerable<IMigrationRule> rules, string projectJson,
string testDirectory)
{
var projectContext = GenerateProjectContextFromString(testDirectory, projectJson);
return RunMigrationRulesOnGeneratedProject(rules, projectContext, testDirectory);
}
private static ProjectContext GenerateProjectContextFromString(string projectDirectory, string json)
{
var testPj = new ProjectJsonBuilder(null)
.FromStringBase(json)
.SaveToDisk(projectDirectory);
return ProjectContext.Create(testPj, FrameworkConstants.CommonFrameworks.NetCoreApp10);
}
private static ProjectRootElement RunMigrationRulesOnGeneratedProject(IEnumerable<IMigrationRule> rules,
ProjectContext projectContext, string testDirectory)
{
var project = ProjectRootElement.Create();
var testSettings = new MigrationSettings(testDirectory, testDirectory, "1.0.0", project);
var testInputs = new MigrationRuleInputs(new[] {projectContext}, project,
project.AddItemGroup(),
project.AddPropertyGroup());
foreach (var rule in rules)
{
rule.Apply(testSettings, testInputs);
}
return project;
}
}
}

View file

@ -0,0 +1,44 @@
using Microsoft.DotNet.ProjectJsonMigration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
using FluentAssertions;
using Microsoft.Build.Construction;
namespace Microsoft.DotNet.ProjectJsonMigration.Tests
{
public class GivenAConditionalTransform
{
[Fact]
public void It_returns_null_when_condition_is_false()
{
var conditionalTransform = new TestConditionalTransform(t => false);
conditionalTransform.Transform("astring").Should().BeNull();
}
[Fact]
public void It_returns_result_of_ConditionallyTransform_when_condition_is_true()
{
var conditionalTransform = new TestConditionalTransform(t => true);
var property = conditionalTransform.Transform("astring");
property.Should().NotBeNull();
property.Name.Should().Be("astring");
property.Value.Should().Be("astring");
}
private class TestConditionalTransform : ConditionalTransform<string, ProjectPropertyElement>
{
public TestConditionalTransform(Func<string, bool> condition) : base(condition) { }
public override ProjectPropertyElement ConditionallyTransform(string source)
{
var property = ProjectRootElement.Create().CreatePropertyElement(source);
property.Value = source;
return property;
}
}
}
}

View file

@ -0,0 +1,89 @@
using System;
using Microsoft.Build.Construction;
using Xunit;
using Xunit.Runner.DotNet;
using FluentAssertions;
using System.Linq;
namespace Microsoft.DotNet.ProjectJsonMigration.Tests.Transforms
{
public class GivenATransformApplicator
{
[Fact]
public void It_merges_Metadata_and_Exclude_with_items_with_same_ItemType_and_Include_when_mergeExisting_is_true()
{
var metadata = new ItemMetadataValue<string>[]
{
new ItemMetadataValue<string>("metadata1", "value1"),
new ItemMetadataValue<string>("metadata2", "value2")
};
var fullItemTransformSetIncludeValue = "include1;include2";
var transform1 = new AddItemTransform<string>("item",
fullItemTransformSetIncludeValue,
"exclude1",
t => true,
mergeExisting: true)
.WithMetadata(metadata[0]);
var transform2 = new AddItemTransform<string>("item",
fullItemTransformSetIncludeValue,
"exclude2",
t => true,
mergeExisting: true)
.WithMetadata(metadata[1]);
var mockProj = ProjectRootElement.Create();
var itemGroup = mockProj.AddItemGroup();
var item1 = transform1.Transform("_");
item1.AddMetadata(metadata[0].MetadataName, metadata[0].GetMetadataValue(null));
var item2 = transform2.Transform("_");
item2.AddMetadata(metadata[1].MetadataName, metadata[1].GetMetadataValue(null));
var transformApplicator = new TransformApplicator();
transformApplicator.Execute(new ProjectItemElement[] {item1, item2}, itemGroup, mergeExisting:true);
itemGroup.Items.Count.Should().Be(1);
var item = itemGroup.Items.First();
item.Exclude.Should().Be("exclude1;exclude2");
item.Metadata.Count().Should().Be(2);
var foundMetadata = metadata.ToDictionary<ItemMetadataValue<string>, string, bool>(m => m.MetadataName,
m => false);
foreach (var metadataEntry in item.Metadata)
{
foundMetadata.Should().ContainKey(metadataEntry.Name);
foundMetadata[metadataEntry.Name].Should().BeFalse();
foundMetadata[metadataEntry.Name] = true;
}
foundMetadata.All(kv => kv.Value).Should().BeTrue();
}
// [Fact]
// public void It_adds_duplicate_properties_to_the_project_with_specified_value_when_the_property_exists()
// {
// var mockProj = ProjectRootElement.Create();
// var propertyGroup = mockProj.AddPropertyGroup();
// var propertyName = "Property1";
// var propertyValue = "Value1";
//
// var propertyTransform = new AddPropertyTransform<string>(propertyName, propertyValue, t => true);
// propertyTransform.Transform("_");
// propertyTransform.Transform("_", mockProj, propertyGroup);
//
// propertyGroup.Properties.Count.Should().Be(2);
//
// foreach (var property in propertyGroup.Properties)
// {
// property.Name.Should().Be(propertyName);
// property.Value.Should().Be(propertyValue);
// }
// }
}
}

View file

@ -0,0 +1,39 @@
using Microsoft.Build.Construction;
using Microsoft.DotNet.ProjectJsonMigration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
using FluentAssertions;
namespace Microsoft.DotNet.Migration.Tests
{
public class GivenAnAddBoolPropertyTransform
{
[Theory]
[InlineData(true)]
[InlineData(false)]
public void It_returns_a_property_to_the_project_with_boolean_value(bool propertyValue)
{
var propertyName = "Property1";
var propertyTransform = new AddBoolPropertyTransform(propertyName, t => true);
var property = propertyTransform.Transform(propertyValue);
property.Name.Should().Be(propertyName);
property.Value.Should().Be(propertyValue.ToString());
}
[Theory]
[InlineData(true)]
[InlineData(false)]
public void It_returns_null_when_condition_is_false(bool propertyValue)
{
var propertyName = "Property1";
var propertyTransform = new AddBoolPropertyTransform(propertyName, t => false);
propertyTransform.Transform(propertyValue).Should().BeNull();
}
}
}

View file

@ -0,0 +1,84 @@
using Microsoft.Build.Construction;
using Microsoft.DotNet.ProjectJsonMigration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
using FluentAssertions;
namespace Microsoft.DotNet.Migration.Tests
{
public class GivenAnAddItemTransform
{
[Fact]
public void It_returns_an_item_with_Include_Exclude_and_Metadata_to_project_when_condition_is_true()
{
var itemTransforms = GetFullItemTransformSet(true);
foreach (var transform in itemTransforms)
{
var item = transform.Transform("_");
item.Should().NotBeNull();
item.Include.Should().Be(FullItemTransformSetIncludeValue);
item.Exclude.Should().Be(FullItemTransformSetExcludeValue);
item.HasMetadata.Should().BeTrue();
var metadata = item.Metadata.First();
metadata.Name.Should().Be(FullItemTransformSetMetadataName);
metadata.Value.Should().Be(FullItemTransformSetMetadataValue);
}
}
[Fact]
public void It_returns_null_when_condition_is_false()
{
var itemTransforms = GetFullItemTransformSet(false);
foreach (var transform in itemTransforms)
{
transform.Transform("_").Should().BeNull();
}
}
private static string FullItemTransformSetItemNamePrefix => "item";
private static string FullItemTransformSetIncludeValue => "include1;include2";
private static string FullItemTransformSetExcludeValue => "exclude1;exclude2";
private static string FullItemTransformSetMetadataName => "SomeName";
private static string FullItemTransformSetMetadataValue => "SomeValue";
private AddItemTransform<string>[] GetFullItemTransformSet(bool condition)
{
return new AddItemTransform<string>[]
{
new AddItemTransform<string>(FullItemTransformSetItemNamePrefix + "1",
FullItemTransformSetIncludeValue.Split(';'),
FullItemTransformSetExcludeValue.Split(';'),
t => condition)
.WithMetadata(FullItemTransformSetMetadataName, FullItemTransformSetMetadataValue),
new AddItemTransform<string>(FullItemTransformSetItemNamePrefix + "2",
t => FullItemTransformSetIncludeValue,
t => FullItemTransformSetExcludeValue,
t => condition)
.WithMetadata(FullItemTransformSetMetadataName, t => FullItemTransformSetMetadataValue),
new AddItemTransform<string>(FullItemTransformSetItemNamePrefix + "3",
FullItemTransformSetIncludeValue,
t => FullItemTransformSetExcludeValue,
t => condition)
.WithMetadata(new ItemMetadataValue<string>(FullItemTransformSetMetadataName, FullItemTransformSetMetadataValue)),
new AddItemTransform<string>(FullItemTransformSetItemNamePrefix + "4",
t => FullItemTransformSetIncludeValue,
FullItemTransformSetExcludeValue,
t => condition)
.WithMetadata(new ItemMetadataValue<string>(FullItemTransformSetMetadataName, t => FullItemTransformSetMetadataValue)),
new AddItemTransform<string>(FullItemTransformSetItemNamePrefix + "5",
FullItemTransformSetIncludeValue,
FullItemTransformSetExcludeValue,
t => condition)
.WithMetadata(FullItemTransformSetMetadataName, FullItemTransformSetMetadataValue)
};
}
}
}

View file

@ -0,0 +1,93 @@
using Microsoft.Build.Construction;
using Microsoft.DotNet.ProjectJsonMigration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
using FluentAssertions;
namespace Microsoft.DotNet.Migration.Tests
{
public class GivenAnAddPropertyTransform
{
[Fact]
public void It_returns_a_property_with_specified_value()
{
var propertyName = "Property1";
var propertyValue = "Value1";
var propertyTransform = new AddPropertyTransform<string>(propertyName, propertyValue, t=>true);
var property = propertyTransform.Transform("_");
property.Name.Should().Be(propertyName);
property.Value.Should().Be(propertyValue);
}
[Fact]
public void It_returns_a_property_with_computed_value()
{
var propertyName = "Property1";
var propertyValue = "Value1";
var propertyTransform = new AddPropertyTransform<string>(propertyName, t => t.ToUpper(), t => true);
var property = propertyTransform.Transform(propertyValue);
property.Name.Should().Be(propertyName);
property.Value.Should().Be(propertyValue.ToUpper());
}
[Fact]
public void It_returns_null_when_condition_is_false()
{
var propertyName = "Property1";
var propertyValue = "Value1";
var propertyTransform = new AddPropertyTransform<string>(propertyName, propertyValue, t => false);
propertyTransform.Transform(propertyValue).Should().BeNull();
}
[Fact]
public void It_returns_a_property_when_source_is_null_and_propertyValue_is_a_string()
{
var propertyName = "Property1";
var propertyValue = "Value1";
var propertyTransform = new AddPropertyTransform<string>(
propertyName,
propertyValue,
t => true);
var property = propertyTransform.Transform(null);
property.Should().NotBeNull();
property.Value.Should().Be(propertyValue);
}
[Fact]
public void It_returns_a_property_when_source_is_null_and_propertyValue_is_a_Func_that_handles_null()
{
var propertyName = "Property1";
var propertyValue = "Value1";
var propertyTransform = new AddPropertyTransform<string>(
propertyName,
t=> t == null ? propertyValue.ToUpper() : propertyValue.ToLower(),
t => true);
var property = propertyTransform.Transform(null);
property.Value.Should().Be(propertyValue.ToUpper());
}
[Fact]
public void It_throws_when_source_is_null_and_propertyValue_is_a_Func_that_doesnt_handle_null()
{
var propertyName = "Property1";
var propertyTransform = new AddPropertyTransform<string>(
propertyName,
t => t.ToUpper(),
t => true);
Action transform = () => propertyTransform.Transform(null);
transform.ShouldThrow<Exception>();
}
}
}

View file

@ -0,0 +1,57 @@
using Microsoft.Build.Construction;
using Microsoft.DotNet.ProjectJsonMigration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
using FluentAssertions;
namespace Microsoft.DotNet.Migration.Tests
{
public class GivenAnAddStringPropertyTransform
{
[Fact]
public void It_adds_a_property_to_the_project_with_string_value()
{
var propertyName = "Property1";
var propertyValue = "TestValue1";
var propertyTransform = new AddStringPropertyTransform(propertyName, t => true);
var property = propertyTransform.Transform(propertyValue);
property.Name.Should().Be(propertyName);
property.Value.Should().Be(propertyValue);
}
[Fact]
public void It_returns_null_when_propertyValue_is_null_and_condition_is_passed()
{
var propertyName = "Property1";
string propertyValue = null;
var propertyTransform = new AddStringPropertyTransform(propertyName, t => true);
propertyTransform.Transform(propertyValue).Should().BeNull();
}
[Fact]
public void It_returns_null_when_propertyValue_is_null_and_condition_is_not_passed()
{
var mockProj = ProjectRootElement.Create();
var propertyName = "Property1";
string propertyValue = null;
var propertyTransform = new AddStringPropertyTransform(propertyName);
propertyTransform.Transform(propertyValue).Should().BeNull();
}
[Fact]
public void It_returns_null_when_condition_is_false()
{
var propertyName = "Property1";
var propertyValue = "TestValue1";
var propertyTransform = new AddStringPropertyTransform(propertyName, t => false);
propertyTransform.Transform(propertyValue).Should().BeNull();
}
}
}

View file

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.DotNet.Migration.Tests
{
public class GivenAnIncludeContextTransformation
{
}
}

View file

@ -0,0 +1,39 @@
{
"version": "1.0.0-*",
"buildOptions": {
"copyToOutput": ["MSBuild.exe", "msbuild.exe.config"]
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"Microsoft.DotNet.ProjectJsonMigration": {
"target": "project"
},
"xunit": "2.2.0-beta3-build3330",
"dotnet-test-xunit": "1.0.0-rc2-318883-21",
"FluentAssertions": "4.0.0",
"moq.netcore": "4.4.0-beta8",
"Microsoft.DotNet.Tools.Tests.Utilities": {
"target": "project"
},
"Microsoft.DotNet.Cli.Utils": {
"target": "project"
},
"dotnet": {
"target":"project"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"netstandardapp1.5",
"dotnet5.4",
"portable-net451+win8"
]
}
},
"testRunner": "xunit"
}