Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 5c0ecbb

Browse files
committed
Add xproj tests to test migrate command.
1 parent d43ade9 commit 5c0ecbb

File tree

6 files changed

+63
-2
lines changed

6 files changed

+63
-2
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
</PropertyGroup>
7+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
8+
<PropertyGroup Label="Globals">
9+
<ProjectGuid>084222f1-7909-48f4-81e8-a97398b26b1c</ProjectGuid>
10+
<RootNamespace>ProjectC</RootNamespace>
11+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">obj</BaseIntermediateOutputPath>
12+
<OutputPath Condition="'$(OutputPath)'=='' ">bin</OutputPath>
13+
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
14+
</PropertyGroup>
15+
<PropertyGroup>
16+
<SchemaVersion>2.0</SchemaVersion>
17+
</PropertyGroup>
18+
<ItemGroup>
19+
<ProjectReference Include="..\..\ClassLibrary1\ClassLibrary1.csproj" />
20+
<ProjectReference Include="..\..\ClassLibrary2\ClassLibrary2.csproj" />
21+
</ItemGroup>
22+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
23+
</Project>

TestAssets/TestProjects/TestAppDependencyGraph/ProjectC/project.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
"target": "project",
1919
"version": "1.0.0-*"
2020
},
21+
"ClassLibrary1": {
22+
"target": "project"
23+
},
24+
"ClassLibrary2": {
25+
"target": "project"
26+
},
2127
"NETStandard.Library": "1.6.0"
2228
},
2329
"frameworks": {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
</PropertyGroup>
7+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
8+
<PropertyGroup Label="Globals">
9+
<ProjectGuid>7fb8f138-ffb0-4eec-af9e-2e6ff9979593</ProjectGuid>
10+
<RootNamespace>ProjectE</RootNamespace>
11+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">obj</BaseIntermediateOutputPath>
12+
<OutputPath Condition="'$(OutputPath)'=='' ">bin</OutputPath>
13+
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
14+
</PropertyGroup>
15+
<PropertyGroup>
16+
<SchemaVersion>2.0</SchemaVersion>
17+
</PropertyGroup>
18+
<ItemGroup>
19+
<ProjectReference Include="..\..\ClassLibrary2\ClassLibrary2.csproj" />
20+
<ProjectReference Include="..\..\ClassLibrary3\ClassLibrary3.csproj" />
21+
</ItemGroup>
22+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
23+
</Project>

TestAssets/TestProjects/TestAppDependencyGraph/ProjectE/project.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
]
1111
},
1212
"dependencies": {
13+
"ClassLibrary2": {
14+
"target": "project"
15+
},
16+
"ClassLibrary3": {
17+
"target": "project"
18+
},
1319
"NETStandard.Library": "1.6.0"
1420
},
1521
"frameworks": {

src/Microsoft.DotNet.ProjectJsonMigration/ProjectDependencyFinder.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Newtonsoft.Json.Linq;
1111
using Microsoft.DotNet.ProjectModel.Compilation;
1212
using Microsoft.DotNet.ProjectModel.Graph;
13+
using Microsoft.DotNet.Tools.Common;
1314

1415
namespace Microsoft.DotNet.ProjectJsonMigration
1516
{
@@ -77,7 +78,8 @@ public IEnumerable<ProjectDependency> ResolveProjectDependencies(ProjectContext
7778
private IEnumerable<string> ResolveXProjProjectDependencyNames(ProjectRootElement xproj)
7879
{
7980
var xprojDependencies = ResolveXProjProjectDependencies(xproj).SelectMany(r => r.Includes());
80-
return new HashSet<string>(xprojDependencies.Select(p => Path.GetFileNameWithoutExtension(p)));
81+
return new HashSet<string>(xprojDependencies.Select(p => Path.GetFileNameWithoutExtension(
82+
PathUtility.GetPathWithDirectorySeparator(p))));
8183
}
8284

8385
internal IEnumerable<ProjectItemElement> ResolveXProjProjectDependencies(ProjectRootElement xproj)

src/Microsoft.DotNet.ProjectJsonMigration/Rules/MigrateProjectDependenciesRule.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public void Apply(MigrationSettings migrationSettings, MigrationRuleInputs migra
3131
_projectDirectory = migrationSettings.ProjectDirectory;
3232

3333
var migratedXProjDependencyPaths = MigrateXProjProjectDependencies(migrationRuleInputs);
34-
var migratedXProjDependencyNames = new HashSet<string>(migratedXProjDependencyPaths.Select(p => Path.GetFileNameWithoutExtension(p)));
34+
var migratedXProjDependencyNames = new HashSet<string>(migratedXProjDependencyPaths.Select(p => Path.GetFileNameWithoutExtension(
35+
PathUtility.GetPathWithDirectorySeparator(p))));
3536

3637
AddPropertyTransformsToCommonPropertyGroup(migrationRuleInputs.CommonPropertyGroup);
3738
MigrateProjectJsonProjectDependencies(

0 commit comments

Comments
 (0)