Add xproj tests to test migrate command.
This commit is contained in:
parent
d43ade9629
commit
ec7aa87576
10 changed files with 78 additions and 2 deletions
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>084222f1-7909-48f4-81e8-a97398b26b1c</ProjectGuid>
|
||||||
|
<RootNamespace>ProjectC</RootNamespace>
|
||||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">obj</BaseIntermediateOutputPath>
|
||||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">bin</OutputPath>
|
||||||
|
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\ClassLibrary1\ClassLibrary1.csproj" />
|
||||||
|
<ProjectReference Include="..\..\ClassLibrary2\ClassLibrary2.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
</Project>
|
|
@ -18,6 +18,12 @@
|
||||||
"target": "project",
|
"target": "project",
|
||||||
"version": "1.0.0-*"
|
"version": "1.0.0-*"
|
||||||
},
|
},
|
||||||
|
"ClassLibrary1": {
|
||||||
|
"target": "project"
|
||||||
|
},
|
||||||
|
"ClassLibrary2": {
|
||||||
|
"target": "project"
|
||||||
|
},
|
||||||
"NETStandard.Library": "1.6.0"
|
"NETStandard.Library": "1.6.0"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>7fb8f138-ffb0-4eec-af9e-2e6ff9979593</ProjectGuid>
|
||||||
|
<RootNamespace>ProjectE</RootNamespace>
|
||||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">obj</BaseIntermediateOutputPath>
|
||||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">bin</OutputPath>
|
||||||
|
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\ClassLibrary2\ClassLibrary2.csproj" />
|
||||||
|
<ProjectReference Include="..\..\ClassLibrary3\ClassLibrary3.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
</Project>
|
|
@ -10,6 +10,12 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"ClassLibrary2": {
|
||||||
|
"target": "project"
|
||||||
|
},
|
||||||
|
"ClassLibrary3": {
|
||||||
|
"target": "project"
|
||||||
|
},
|
||||||
"NETStandard.Library": "1.6.0"
|
"NETStandard.Library": "1.6.0"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
|
@ -10,6 +10,7 @@ using System.IO;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Microsoft.DotNet.ProjectModel.Compilation;
|
using Microsoft.DotNet.ProjectModel.Compilation;
|
||||||
using Microsoft.DotNet.ProjectModel.Graph;
|
using Microsoft.DotNet.ProjectModel.Graph;
|
||||||
|
using Microsoft.DotNet.Tools.Common;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.ProjectJsonMigration
|
namespace Microsoft.DotNet.ProjectJsonMigration
|
||||||
{
|
{
|
||||||
|
@ -77,7 +78,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration
|
||||||
private IEnumerable<string> ResolveXProjProjectDependencyNames(ProjectRootElement xproj)
|
private IEnumerable<string> ResolveXProjProjectDependencyNames(ProjectRootElement xproj)
|
||||||
{
|
{
|
||||||
var xprojDependencies = ResolveXProjProjectDependencies(xproj).SelectMany(r => r.Includes());
|
var xprojDependencies = ResolveXProjProjectDependencies(xproj).SelectMany(r => r.Includes());
|
||||||
return new HashSet<string>(xprojDependencies.Select(p => Path.GetFileNameWithoutExtension(p)));
|
return new HashSet<string>(xprojDependencies.Select(p => Path.GetFileNameWithoutExtension(
|
||||||
|
PathUtility.GetPathWithDirectorySeparator(p))));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal IEnumerable<ProjectItemElement> ResolveXProjProjectDependencies(ProjectRootElement xproj)
|
internal IEnumerable<ProjectItemElement> ResolveXProjProjectDependencies(ProjectRootElement xproj)
|
||||||
|
|
|
@ -31,7 +31,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
_projectDirectory = migrationSettings.ProjectDirectory;
|
_projectDirectory = migrationSettings.ProjectDirectory;
|
||||||
|
|
||||||
var migratedXProjDependencyPaths = MigrateXProjProjectDependencies(migrationRuleInputs);
|
var migratedXProjDependencyPaths = MigrateXProjProjectDependencies(migrationRuleInputs);
|
||||||
var migratedXProjDependencyNames = new HashSet<string>(migratedXProjDependencyPaths.Select(p => Path.GetFileNameWithoutExtension(p)));
|
var migratedXProjDependencyNames = new HashSet<string>(migratedXProjDependencyPaths.Select(p => Path.GetFileNameWithoutExtension(
|
||||||
|
PathUtility.GetPathWithDirectorySeparator(p))));
|
||||||
|
|
||||||
AddPropertyTransformsToCommonPropertyGroup(migrationRuleInputs.CommonPropertyGroup);
|
AddPropertyTransformsToCommonPropertyGroup(migrationRuleInputs.CommonPropertyGroup);
|
||||||
MigrateProjectJsonProjectDependencies(
|
MigrateProjectJsonProjectDependencies(
|
||||||
|
|
|
@ -124,6 +124,8 @@ namespace Microsoft.DotNet.Migration.Tests
|
||||||
var projectDirectory =
|
var projectDirectory =
|
||||||
TestAssetsManager.CreateTestInstance("TestAppDependencyGraph", callingMethod: $"{projectName}.RefsTest").Path;
|
TestAssetsManager.CreateTestInstance("TestAppDependencyGraph", callingMethod: $"{projectName}.RefsTest").Path;
|
||||||
|
|
||||||
|
FixUpProjectJsons(projectDirectory);
|
||||||
|
|
||||||
MigrateProject(Path.Combine(projectDirectory, projectName));
|
MigrateProject(Path.Combine(projectDirectory, projectName));
|
||||||
|
|
||||||
string[] migratedProjects = expectedProjects.Split(new char[] { ',' });
|
string[] migratedProjects = expectedProjects.Split(new char[] { ',' });
|
||||||
|
@ -146,6 +148,8 @@ namespace Microsoft.DotNet.Migration.Tests
|
||||||
var projectDirectory =
|
var projectDirectory =
|
||||||
TestAssetsManager.CreateTestInstance("TestAppDependencyGraph", callingMethod: $"{projectName}.SkipRefsTest").Path;
|
TestAssetsManager.CreateTestInstance("TestAppDependencyGraph", callingMethod: $"{projectName}.SkipRefsTest").Path;
|
||||||
|
|
||||||
|
FixUpProjectJsons(projectDirectory);
|
||||||
|
|
||||||
MigrateCommand.Run(new [] { "-p", Path.Combine(projectDirectory, projectName), "--skip-project-references" }).Should().Be(0);
|
MigrateCommand.Run(new [] { "-p", Path.Combine(projectDirectory, projectName), "--skip-project-references" }).Should().Be(0);
|
||||||
|
|
||||||
var migratedProjects = Directory.EnumerateFiles(projectDirectory, "*.csproj", SearchOption.AllDirectories);
|
var migratedProjects = Directory.EnumerateFiles(projectDirectory, "*.csproj", SearchOption.AllDirectories);
|
||||||
|
@ -155,6 +159,17 @@ namespace Microsoft.DotNet.Migration.Tests
|
||||||
migratedProject.Should().Be($"{projectName}.csproj");
|
migratedProject.Should().Be($"{projectName}.csproj");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FixUpProjectJsons(string projectDirectory)
|
||||||
|
{
|
||||||
|
var pjs = Directory.EnumerateFiles(projectDirectory, "project.json.1", SearchOption.AllDirectories);
|
||||||
|
|
||||||
|
foreach(var pj in pjs)
|
||||||
|
{
|
||||||
|
var newPj = pj.Replace("project.json.1", "project.json");
|
||||||
|
File.Move(pj, newPj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private MigratedBuildComparisonData GetDotnetNewComparisonData(string projectDirectory, string dotnetNewType)
|
private MigratedBuildComparisonData GetDotnetNewComparisonData(string projectDirectory, string dotnetNewType)
|
||||||
{
|
{
|
||||||
DotnetNew(projectDirectory, dotnetNewType);
|
DotnetNew(projectDirectory, dotnetNewType);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue