Fixing full framework tests.

This commit is contained in:
Livar Cunha 2017-01-05 22:55:43 -08:00
parent abe7641f03
commit 7e5f18b584
4 changed files with 42 additions and 41 deletions

View file

@ -5,21 +5,6 @@
},
"dependencies": {},
"frameworks": {
"net20": {
"frameworkAssemblies": {
"System.Xml": {}
}
},
"net35": {
"frameworkAssemblies": {
"System.Xml": {}
}
},
"net40": {
"frameworkAssemblies": {
"System.Xml": {}
}
},
"net461": {
"frameworkAssemblies": {
"System.Xml": {}
@ -27,7 +12,10 @@
},
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NetCore.App": "1.0.1"
"Microsoft.NetCore.App": {
"version": "1.0.1",
"type": "platform"
}
}
}
}

View file

@ -149,9 +149,11 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
" OR ",
projectContexts.Where(p => p.IsFullFramework()).Select(
p => $"'$(TargetFramework)' == '{p.TargetFramework.GetShortFolderName()}'"));
msBuildCondition = $" {msBuildCondition} ";
}
return $" {msBuildCondition} ";
return msBuildCondition;
});
}
}

View file

@ -14,7 +14,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
private string _configuration;
private NuGetFramework _framework;
private string _framework;
private string _runtime;
@ -72,6 +72,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
}
public BuildCommand WithFramework(NuGetFramework framework)
{
_framework = framework.GetShortFolderName();
return this;
}
public BuildCommand WithFramework(string framework)
{
_framework = framework;
@ -137,7 +144,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
return null;
}
return $"--framework {_framework.GetShortFolderName()}";
return $"--framework {_framework}";
}
private string GetRuntime()

View file

@ -27,26 +27,6 @@ namespace Microsoft.DotNet.Migration.Tests
[InlineData("AppWithAssemblyInfo")]
[InlineData("TestAppWithEmbeddedResources")]
public void ItMigratesApps(string projectName)
{
var projectDirectory = MigrateApps(projectName);
VerifyAllMSBuildOutputsRunnable(projectDirectory);
var outputCsProj = Path.Combine(projectDirectory, projectName + ".csproj");
var csproj = File.ReadAllText(outputCsProj);
csproj.EndsWith("\n").Should().Be(true);
}
[WindowsOnlyTheory]
[InlineData("TestAppWithMultipleFrameworksAndRuntimes")]
[InlineData("TestAppWithMultipleFrameworksAndNoRuntimes")]
[InlineData("TestAppWithMultipleFrameworksOnly")]
public void ItMigratesAppsWithFullFramework(string projectName)
{
MigrateApps(projectName);
}
private string MigrateApps(string projectName)
{
var projectDirectory = TestAssetsManager.CreateTestInstance(projectName, identifier: projectName)
.WithLockFiles()
@ -66,7 +46,29 @@ namespace Microsoft.DotNet.Migration.Tests
outputsIdentical.Should().BeTrue();
return projectDirectory;
VerifyAllMSBuildOutputsRunnable(projectDirectory);
var outputCsProj = Path.Combine(projectDirectory, projectName + ".csproj");
var csproj = File.ReadAllText(outputCsProj);
csproj.EndsWith("\n").Should().Be(true);
}
[WindowsOnlyTheory]
[InlineData("TestAppWithMultipleFrameworksAndNoRuntimes", null)]
[InlineData("TestAppWithMultipleFullFrameworksOnly", "net461")]
public void ItMigratesAppsWithFullFramework(string projectName, string framework)
{
var projectDirectory = TestAssetsManager.CreateTestInstance(
projectName,
identifier: projectName).WithLockFiles().Path;
CleanBinObj(projectDirectory);
MigrateProject(new [] { projectDirectory });
Restore(projectDirectory);
BuildMSBuild(projectDirectory, projectName, framework: framework);
}
[Fact]
@ -711,7 +713,8 @@ namespace Microsoft.DotNet.Migration.Tests
string projectDirectory,
string projectName,
string configuration="Debug",
string runtime=null)
string runtime=null,
string framework=null)
{
if (projectName != null && !Path.HasExtension(projectName))
{
@ -723,6 +726,7 @@ namespace Microsoft.DotNet.Migration.Tests
var result = new BuildCommand()
.WithWorkingDirectory(projectDirectory)
.WithRuntime(runtime)
.WithFramework(framework)
.ExecuteWithCapturedOutput($"{projectName} /p:Configuration={configuration}");
result