Improve sln migration tests (#5066)
* WIP Improve sln migration tests * Simple migration test * Improve the test * WIP update test assets * Update test * Test a bug fix * Add another migrate sln test * Fix FilePath related tests * Finish the migrate sln tests * Fix tests * Fix another path issue
This commit is contained in:
parent
7a2c6ad086
commit
89f0b05958
45 changed files with 690 additions and 65 deletions
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Hello from main");
|
||||||
|
Console.WriteLine(TestLibrary.Lib.GetMessage());
|
||||||
|
Console.WriteLine(subdir.Helper.GetMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 14
|
||||||
|
VisualStudioVersion = 14.0.25420.1
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestApp", "TestApp.xproj", "{411BC0C0-497A-45C2-B6F7-0B428A6A9AEF}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestLibrary", "..\TestLibrary\TestLibrary.xproj", "{B2E306B6-B490-46AC-A421-AA3B7D38EDF0}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{411BC0C0-497A-45C2-B6F7-0B428A6A9AEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{411BC0C0-497A-45C2-B6F7-0B428A6A9AEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{411BC0C0-497A-45C2-B6F7-0B428A6A9AEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{411BC0C0-497A-45C2-B6F7-0B428A6A9AEF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B2E306B6-B490-46AC-A421-AA3B7D38EDF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B2E306B6-B490-46AC-A421-AA3B7D38EDF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B2E306B6-B490-46AC-A421-AA3B7D38EDF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B2E306B6-B490-46AC-A421-AA3B7D38EDF0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?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>0138cb8f-4aa9-4029-a21e-c07c30f425ba</ProjectGuid>
|
||||||
|
<RootNamespace>TestApp</RootNamespace>
|
||||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
||||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||||
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="src\subdir\subdir.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"buildOptions": {
|
||||||
|
"emitEntryPoint": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"type": "platform",
|
||||||
|
"version": "1.0.1"
|
||||||
|
},
|
||||||
|
"TestLibrary": {
|
||||||
|
"target": "project",
|
||||||
|
"version": "1.0.0-*"
|
||||||
|
},
|
||||||
|
"subdir": {
|
||||||
|
"target": "project",
|
||||||
|
"version": "1.0.0-*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"frameworks": {
|
||||||
|
"netcoreapp1.0": {
|
||||||
|
"imports": "dnxcore50"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
namespace subdir
|
||||||
|
{
|
||||||
|
public static class Helper
|
||||||
|
{
|
||||||
|
public static string GetMessage()
|
||||||
|
{
|
||||||
|
return "This string came from the subdir test library!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard1.5</TargetFramework>
|
||||||
|
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||||
|
<AssemblyName>subdir</AssemblyName>
|
||||||
|
<PackageId>subdir</PackageId>
|
||||||
|
<ProjectGuid>F8F96F4A-F10C-4C54-867C-A9EFF55494C8</ProjectGuid>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="**\*.cs" />
|
||||||
|
<EmbeddedResource Include="**\*.resx" Exclude="@(EmbeddedResource)" />
|
||||||
|
<EmbeddedResource Include="compiler\resources\**\*" Exclude="@(EmbeddedResource)" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="NETStandard.Library">
|
||||||
|
<Version>1.6.0</Version>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
|
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TestLibrary
|
||||||
|
{
|
||||||
|
public static class Lib
|
||||||
|
{
|
||||||
|
public static string GetMessage()
|
||||||
|
{
|
||||||
|
return "Hello from TestLibrary.Lib";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?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>dc0b35d0-8a36-4b52-8a11-b86739f055d2</ProjectGuid>
|
||||||
|
<RootNamespace>TestLibrary</RootNamespace>
|
||||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
||||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||||
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
|
||||||
|
"dependencies": {
|
||||||
|
"NETStandard.Library": "1.6.0"
|
||||||
|
},
|
||||||
|
|
||||||
|
"frameworks": {
|
||||||
|
"netstandard1.6": {
|
||||||
|
"imports": "dnxcore50"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ namespace TestApp
|
||||||
public static int Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
Console.WriteLine(TestLibrary.Helper.GetMessage());
|
Console.WriteLine(TestLibrary.Helper.GetMessage());
|
||||||
|
Console.WriteLine(subdir.Helper.GetMessage());
|
||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,11 +7,18 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestApp", "TestApp.xproj",
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestLibrary", "..\TestLibrary\TestLibrary.xproj", "{DC0B35D0-8A36-4B52-8A11-B86739F055D2}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestLibrary", "..\TestLibrary\TestLibrary.xproj", "{DC0B35D0-8A36-4B52-8A11-B86739F055D2}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "subdir", "src\subdir\subdir.xproj", "{F8F96F4A-F10C-4C54-867C-A9EFF55494C8}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{0138CB8F-4AA9-4029-A21E-C07C30F425BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{0138CB8F-4AA9-4029-A21E-C07C30F425BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{DC0B35D0-8A36-4B52-8A11-B86739F055D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{DC0B35D0-8A36-4B52-8A11-B86739F055D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{0138CB8F-4AA9-4029-A21E-C07C30F425BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{0138CB8F-4AA9-4029-A21E-C07C30F425BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{0138CB8F-4AA9-4029-A21E-C07C30F425BA}.Release|Any CPU.Build.0 = Release|Any CPU
|
{0138CB8F-4AA9-4029-A21E-C07C30F425BA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{DC0B35D0-8A36-4B52-8A11-B86739F055D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{DC0B35D0-8A36-4B52-8A11-B86739F055D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
@ -9,6 +9,10 @@
|
||||||
"target": "project",
|
"target": "project",
|
||||||
"version": "1.0.0-*"
|
"version": "1.0.0-*"
|
||||||
},
|
},
|
||||||
|
"subdir": {
|
||||||
|
"target": "project",
|
||||||
|
"version": "1.0.0-*"
|
||||||
|
},
|
||||||
"Microsoft.NETCore.App": "1.0.1"
|
"Microsoft.NETCore.App": "1.0.1"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
|
@ -0,0 +1,15 @@
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
namespace subdir
|
||||||
|
{
|
||||||
|
public static class Helper
|
||||||
|
{
|
||||||
|
public static string GetMessage()
|
||||||
|
{
|
||||||
|
return "This string came from the subdir test library!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0.23107" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.23107</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>F8F96F4A-F10C-4C54-867C-A9EFF55494C8</ProjectGuid>
|
||||||
|
<RootNamespace>TestAppWithContents</RootNamespace>
|
||||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\</OutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"buildOptions": {
|
||||||
|
"nowarn": [
|
||||||
|
"CS1591"
|
||||||
|
],
|
||||||
|
"additionalArguments": [
|
||||||
|
"-highentropyva+"
|
||||||
|
]
|
||||||
|
},"dependencies": {
|
||||||
|
"NETStandard.Library": "1.6.0"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"netstandard1.5": {}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard1.4</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="**\*.cs" />
|
||||||
|
<EmbeddedResource Include="**\*.resx" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="NETStandard.Library" Version="1.6" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,18 @@
|
||||||
|
// 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;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static int Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine(TestLibrary.Helper.GetMessage());
|
||||||
|
Console.WriteLine(subdir.Helper.GetMessage());
|
||||||
|
return 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 14
|
||||||
|
VisualStudioVersion = 14.0.25420.1
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestApp", "TestApp.xproj", "{0138CB8F-4AA9-4029-A21E-C07C30F425BA}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestLibrary", "..\TestLibrary\TestLibrary.xproj", "{DC0B35D0-8A36-4B52-8A11-B86739F055D2}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "subdir", "src\subdir\subdir.xproj", "{F8F96F4A-F10C-4C54-867C-A9EFF55494C8}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{0138CB8F-4AA9-4029-A21E-C07C30F425BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{0138CB8F-4AA9-4029-A21E-C07C30F425BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{DC0B35D0-8A36-4B52-8A11-B86739F055D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{DC0B35D0-8A36-4B52-8A11-B86739F055D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{0138CB8F-4AA9-4029-A21E-C07C30F425BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{0138CB8F-4AA9-4029-A21E-C07C30F425BA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{DC0B35D0-8A36-4B52-8A11-B86739F055D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{DC0B35D0-8A36-4B52-8A11-B86739F055D2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0.23107" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.23107</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>0138cb8f-4aa9-4029-a21e-c07c30f425ba</ProjectGuid>
|
||||||
|
<RootNamespace>TestAppWithContents</RootNamespace>
|
||||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\</OutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"buildOptions": {
|
||||||
|
"emitEntryPoint": true,
|
||||||
|
"preserveCompilationContext": true
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"TestLibrary": {
|
||||||
|
"target": "project",
|
||||||
|
"version": "1.0.0-*"
|
||||||
|
},
|
||||||
|
"subdir": {
|
||||||
|
"target": "project",
|
||||||
|
"version": "1.0.0-*"
|
||||||
|
},
|
||||||
|
"Microsoft.NETCore.App": "1.0.1"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"netcoreapp1.0": {}
|
||||||
|
},
|
||||||
|
"runtimes": {
|
||||||
|
"win7-x64": {},
|
||||||
|
"win7-x86": {},
|
||||||
|
"osx.10.10-x64": {},
|
||||||
|
"osx.10.11-x64": {},
|
||||||
|
"ubuntu.14.04-x64": {},
|
||||||
|
"ubuntu.16.04-x64": {},
|
||||||
|
"centos.7-x64": {},
|
||||||
|
"rhel.7.2-x64": {},
|
||||||
|
"debian.8-x64": {},
|
||||||
|
"fedora.23-x64": {},
|
||||||
|
"opensuse.13.2-x64": {}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
namespace subdir
|
||||||
|
{
|
||||||
|
public static class Helper
|
||||||
|
{
|
||||||
|
public static string GetMessage()
|
||||||
|
{
|
||||||
|
return "This string came from the subdir test library!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"buildOptions": {
|
||||||
|
"nowarn": [
|
||||||
|
"CS1591"
|
||||||
|
],
|
||||||
|
"additionalArguments": [
|
||||||
|
"-highentropyva+"
|
||||||
|
]
|
||||||
|
},"dependencies": {
|
||||||
|
"NETStandard.Library": "1.6.0"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"netstandard1.5": {}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0.23107" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.23107</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>F8F96F4A-F10C-4C54-867C-A9EFF55494C8</ProjectGuid>
|
||||||
|
<RootNamespace>TestAppWithContents</RootNamespace>
|
||||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\</OutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,15 @@
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
namespace TestLibrary
|
||||||
|
{
|
||||||
|
public static class Helper
|
||||||
|
{
|
||||||
|
public static string GetMessage()
|
||||||
|
{
|
||||||
|
return "This string came from the test library!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0.23107" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.23107</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>dc0b35d0-8a36-4b52-8a11-b86739f055d2</ProjectGuid>
|
||||||
|
<RootNamespace>TestAppWithContents</RootNamespace>
|
||||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\</OutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"buildOptions": {
|
||||||
|
"nowarn": [
|
||||||
|
"CS1591"
|
||||||
|
],
|
||||||
|
"additionalArguments": [
|
||||||
|
"-highentropyva+"
|
||||||
|
]
|
||||||
|
},"dependencies": {
|
||||||
|
"NETStandard.Library": "1.6.0"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"netstandard1.5": {}
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,6 +17,10 @@
|
||||||
<Compile Include="**\*.cs" />
|
<Compile Include="**\*.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="../Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NET.Sdk">
|
<PackageReference Include="Microsoft.NET.Sdk">
|
||||||
<Version>$(CLI_NETSDK_Version)</Version>
|
<Version>$(CLI_NETSDK_Version)</Version>
|
||||||
|
|
|
@ -31,10 +31,10 @@ using System.Collections.ObjectModel;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.DotNet.Cli.Sln.Internal.FileManipulation;
|
using Microsoft.DotNet.Cli.Sln.Internal.FileManipulation;
|
||||||
|
using Microsoft.DotNet.Tools.Common;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli.Sln.Internal
|
namespace Microsoft.DotNet.Cli.Sln.Internal
|
||||||
{
|
{
|
||||||
|
@ -254,7 +254,20 @@ namespace Microsoft.DotNet.Cli.Sln.Internal
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
public string TypeGuid { get; set; }
|
public string TypeGuid { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string FilePath { get; set; }
|
|
||||||
|
private string _filePath;
|
||||||
|
public string FilePath
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _filePath;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_filePath = PathUtility.GetPathWithDirectorySeparator(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int Line { get; private set; }
|
public int Line { get; private set; }
|
||||||
internal bool Processed { get; set; }
|
internal bool Processed { get; set; }
|
||||||
|
|
||||||
|
@ -337,7 +350,7 @@ namespace Microsoft.DotNet.Cli.Sln.Internal
|
||||||
writer.Write("\") = \"");
|
writer.Write("\") = \"");
|
||||||
writer.Write(Name);
|
writer.Write(Name);
|
||||||
writer.Write("\", \"");
|
writer.Write("\", \"");
|
||||||
writer.Write(FilePath);
|
writer.Write(PathUtility.GetPathWithBackSlashes(FilePath));
|
||||||
writer.Write("\", \"");
|
writer.Write("\", \"");
|
||||||
writer.Write(Id);
|
writer.Write(Id);
|
||||||
writer.WriteLine("\"");
|
writer.WriteLine("\"");
|
||||||
|
|
|
@ -326,7 +326,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var projectDirectory in directory.EnumerateDirectories())
|
foreach (var projectDirectory in
|
||||||
|
Enumerable.Repeat(directory, 1).Union(directory.GetDirectories()))
|
||||||
{
|
{
|
||||||
// Create the path to the project.json file.
|
// Create the path to the project.json file.
|
||||||
var projectFilePath = Path.Combine(projectDirectory.FullName, "project.json");
|
var projectFilePath = Path.Combine(projectDirectory.FullName, "project.json");
|
||||||
|
|
|
@ -157,8 +157,33 @@ namespace Microsoft.DotNet.ProjectJsonMigration
|
||||||
return new ProjectMigrationReport(migrationSettings.ProjectDirectory, projectName, error, null);
|
return new ProjectMigrationReport(migrationSettings.ProjectDirectory, projectName, error, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<string> csprojDependencies = null;
|
||||||
|
if (migrationRuleInputs.ProjectXproj != null)
|
||||||
|
{
|
||||||
|
var projectDependencyFinder = new ProjectDependencyFinder();
|
||||||
|
var dependencies = projectDependencyFinder.ResolveXProjProjectDependencies(
|
||||||
|
migrationRuleInputs.ProjectXproj);
|
||||||
|
|
||||||
|
if (dependencies.Any())
|
||||||
|
{
|
||||||
|
csprojDependencies = dependencies
|
||||||
|
.SelectMany(r => r.Includes().Select(p => PathUtility.GetPathWithDirectorySeparator(p)))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
csprojDependencies = new List<string>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var outputProject = Path.Combine(migrationSettings.OutputDirectory, projectName + ".csproj");
|
var outputProject = Path.Combine(migrationSettings.OutputDirectory, projectName + ".csproj");
|
||||||
return new ProjectMigrationReport(migrationSettings.ProjectDirectory, projectName, outputProject, null);
|
return new ProjectMigrationReport(
|
||||||
|
migrationSettings.ProjectDirectory,
|
||||||
|
projectName,
|
||||||
|
outputProject,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
csprojDependencies);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MigrationRuleInputs ComputeMigrationRuleInputs(MigrationSettings migrationSettings)
|
private MigrationRuleInputs ComputeMigrationRuleInputs(MigrationSettings migrationSettings)
|
||||||
|
|
|
@ -17,6 +17,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration
|
||||||
|
|
||||||
public List<string> Warnings { get; }
|
public List<string> Warnings { get; }
|
||||||
|
|
||||||
|
public List<string> PreExistingCsprojDependencies { get; }
|
||||||
|
|
||||||
public bool Skipped { get; }
|
public bool Skipped { get; }
|
||||||
|
|
||||||
public bool Failed => Errors.Any();
|
public bool Failed => Errors.Any();
|
||||||
|
@ -24,22 +26,38 @@ namespace Microsoft.DotNet.ProjectJsonMigration
|
||||||
public bool Succeeded => !Errors.Any();
|
public bool Succeeded => !Errors.Any();
|
||||||
|
|
||||||
public ProjectMigrationReport(string projectDirectory, string projectName, bool skipped)
|
public ProjectMigrationReport(string projectDirectory, string projectName, bool skipped)
|
||||||
: this(projectDirectory, projectName, null, null, null, skipped: skipped) { }
|
: this(projectDirectory, projectName, null, null, null, null, skipped: skipped) { }
|
||||||
|
|
||||||
public ProjectMigrationReport(string projectDirectory, string projectName, List<MigrationError> errors, List<string> warnings)
|
public ProjectMigrationReport(
|
||||||
: this(projectDirectory, projectName, null, errors, warnings) { }
|
string projectDirectory,
|
||||||
|
string projectName,
|
||||||
|
List<MigrationError> errors,
|
||||||
|
List<string> warnings)
|
||||||
|
: this(projectDirectory, projectName, null, errors, warnings, null) { }
|
||||||
|
|
||||||
public ProjectMigrationReport(string projectDirectory, string projectName, string outputMSBuildProject, List<string> warnings)
|
public ProjectMigrationReport(
|
||||||
: this(projectDirectory, projectName, outputMSBuildProject, null, warnings) { }
|
string projectDirectory,
|
||||||
|
string projectName,
|
||||||
|
string outputMSBuildProject,
|
||||||
|
List<string> warnings)
|
||||||
|
: this(projectDirectory, projectName, outputMSBuildProject, null, warnings, null) { }
|
||||||
|
|
||||||
private ProjectMigrationReport(string projectDirectory, string projectName, string outputMSBuildProject, List<MigrationError> errors, List<string> warnings, bool skipped=false)
|
public ProjectMigrationReport(
|
||||||
|
string projectDirectory,
|
||||||
|
string projectName,
|
||||||
|
string outputMSBuildProject,
|
||||||
|
List<MigrationError> errors,
|
||||||
|
List<string> warnings,
|
||||||
|
List<string> preExistingCsprojDependencies,
|
||||||
|
bool skipped = false)
|
||||||
{
|
{
|
||||||
ProjectDirectory = projectDirectory;
|
ProjectDirectory = projectDirectory;
|
||||||
ProjectName = projectName;
|
ProjectName = projectName;
|
||||||
OutputMSBuildProject = outputMSBuildProject;
|
OutputMSBuildProject = outputMSBuildProject;
|
||||||
Errors = errors ?? new List<MigrationError>();
|
Errors = errors ?? new List<MigrationError>();
|
||||||
Warnings = warnings ?? new List<string>();
|
Warnings = warnings ?? new List<string>();
|
||||||
Skipped=skipped;
|
PreExistingCsprojDependencies = preExistingCsprojDependencies ?? new List<string>();
|
||||||
|
Skipped =skipped;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace Microsoft.DotNet.Tools.Add.ProjectToSolution
|
||||||
|
|
||||||
private void AddProject(SlnFile slnFile, string projectPath)
|
private void AddProject(SlnFile slnFile, string projectPath)
|
||||||
{
|
{
|
||||||
var projectPathNormalized = PathUtility.GetPathWithBackSlashes(projectPath);
|
var projectPathNormalized = PathUtility.GetPathWithDirectorySeparator(projectPath);
|
||||||
|
|
||||||
if (slnFile.Projects.Any((p) =>
|
if (slnFile.Projects.Any((p) =>
|
||||||
string.Equals(p.FilePath, projectPathNormalized, StringComparison.OrdinalIgnoreCase)))
|
string.Equals(p.FilePath, projectPathNormalized, StringComparison.OrdinalIgnoreCase)))
|
||||||
|
|
|
@ -8,6 +8,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.Build.Construction;
|
using Microsoft.Build.Construction;
|
||||||
using Microsoft.Build.Evaluation;
|
using Microsoft.Build.Evaluation;
|
||||||
|
using Microsoft.DotNet.Cli;
|
||||||
using Microsoft.DotNet.Cli.Sln.Internal;
|
using Microsoft.DotNet.Cli.Sln.Internal;
|
||||||
using Microsoft.DotNet.Cli.Utils;
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
using Microsoft.DotNet.ProjectJsonMigration;
|
using Microsoft.DotNet.ProjectJsonMigration;
|
||||||
|
@ -110,24 +111,59 @@ namespace Microsoft.DotNet.Tools.Migrate
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var project in _slnFile.Projects)
|
List<string> csprojFilesToAdd = new List<string>();
|
||||||
{
|
|
||||||
var projectDirectory = Path.Combine(
|
|
||||||
_slnFile.BaseDirectory,
|
|
||||||
Path.GetDirectoryName(project.FilePath));
|
|
||||||
|
|
||||||
var csprojFiles = new DirectoryInfo(projectDirectory)
|
var slnPathWithTrailingSlash = PathUtility.EnsureTrailingSlash(_slnFile.BaseDirectory);
|
||||||
.EnumerateFiles()
|
foreach (var report in migrationReport.ProjectMigrationReports)
|
||||||
.Where(f => f.Extension == ".csproj");
|
|
||||||
|
|
||||||
if (csprojFiles.Count() == 1)
|
|
||||||
{
|
{
|
||||||
project.FilePath = Path.Combine(Path.GetDirectoryName(project.FilePath), csprojFiles.First().Name);
|
var reportPathWithTrailingSlash = PathUtility.EnsureTrailingSlash(report.ProjectDirectory);
|
||||||
project.TypeGuid = ProjectTypeGuids.CSharpProjectTypeGuid;
|
var reportRelPath = Path.Combine(
|
||||||
|
PathUtility.GetRelativePath(slnPathWithTrailingSlash, reportPathWithTrailingSlash),
|
||||||
|
report.ProjectName + ".xproj");
|
||||||
|
|
||||||
|
var projects = _slnFile.Projects.Where(p => p.FilePath == reportRelPath);
|
||||||
|
|
||||||
|
var migratedProjectName = report.ProjectName + ".csproj";
|
||||||
|
if (projects.Count() == 1)
|
||||||
|
{
|
||||||
|
var slnProject = projects.Single();
|
||||||
|
slnProject.FilePath = Path.Combine(
|
||||||
|
Path.GetDirectoryName(slnProject.FilePath),
|
||||||
|
migratedProjectName);
|
||||||
|
slnProject.TypeGuid = ProjectTypeGuids.CSharpProjectTypeGuid;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
csprojFilesToAdd.Add(Path.Combine(report.ProjectDirectory, migratedProjectName));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var preExisting in report.PreExistingCsprojDependencies)
|
||||||
|
{
|
||||||
|
csprojFilesToAdd.Add(Path.Combine(report.ProjectDirectory, preExisting));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_slnFile.Write();
|
_slnFile.Write();
|
||||||
|
|
||||||
|
foreach (var csprojFile in csprojFilesToAdd)
|
||||||
|
{
|
||||||
|
AddProject(_slnFile.FullPath, csprojFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddProject(string slnPath, string csprojPath)
|
||||||
|
{
|
||||||
|
List<string> args = new List<string>()
|
||||||
|
{
|
||||||
|
"add",
|
||||||
|
slnPath,
|
||||||
|
"project",
|
||||||
|
csprojPath,
|
||||||
|
};
|
||||||
|
|
||||||
|
var dotnetPath = Path.Combine(AppContext.BaseDirectory, "dotnet.dll");
|
||||||
|
var addCommand = new ForwardingApp(dotnetPath, args);
|
||||||
|
addCommand.Execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MoveProjectJsonArtifactsToBackup(MigrationReport migrationReport)
|
private void MoveProjectJsonArtifactsToBackup(MigrationReport migrationReport)
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace Microsoft.DotNet.Tools.Remove.ProjectFromSolution
|
||||||
|
|
||||||
private bool RemoveProject(SlnFile slnFile, string projectPath)
|
private bool RemoveProject(SlnFile slnFile, string projectPath)
|
||||||
{
|
{
|
||||||
var projectPathNormalized = PathUtility.GetPathWithBackSlashes(projectPath);
|
var projectPathNormalized = PathUtility.GetPathWithDirectorySeparator(projectPath);
|
||||||
|
|
||||||
var projectsToRemove = slnFile.Projects.Where((p) =>
|
var projectsToRemove = slnFile.Projects.Where((p) =>
|
||||||
string.Equals(p.FilePath, projectPathNormalized, StringComparison.OrdinalIgnoreCase)).ToList();
|
string.Equals(p.FilePath, projectPathNormalized, StringComparison.OrdinalIgnoreCase)).ToList();
|
||||||
|
|
|
@ -185,12 +185,12 @@ Additional Arguments:
|
||||||
.FullName;
|
.FullName;
|
||||||
|
|
||||||
var projectToAdd = "Lib/Lib.csproj";
|
var projectToAdd = "Lib/Lib.csproj";
|
||||||
var normalizedProjectPath = @"Lib\Lib.csproj";
|
var projectPath = Path.Combine("Lib", "Lib.csproj");
|
||||||
var cmd = new DotnetCommand()
|
var cmd = new DotnetCommand()
|
||||||
.WithWorkingDirectory(projectDirectory)
|
.WithWorkingDirectory(projectDirectory)
|
||||||
.ExecuteWithCapturedOutput($"add App.sln project {projectToAdd}");
|
.ExecuteWithCapturedOutput($"add App.sln project {projectToAdd}");
|
||||||
cmd.Should().Pass();
|
cmd.Should().Pass();
|
||||||
cmd.StdOut.Should().Be($"Project `{Path.Combine("Lib", "Lib.csproj")}` added to the solution.");
|
cmd.StdOut.Should().Be($"Project `{projectPath}` added to the solution.");
|
||||||
cmd.StdErr.Should().BeEmpty();
|
cmd.StdErr.Should().BeEmpty();
|
||||||
|
|
||||||
var slnFile = SlnFile.Read(Path.Combine(projectDirectory, "App.sln"));
|
var slnFile = SlnFile.Read(Path.Combine(projectDirectory, "App.sln"));
|
||||||
|
@ -200,7 +200,7 @@ Additional Arguments:
|
||||||
|
|
||||||
matchingProjects.Count.Should().Be(1);
|
matchingProjects.Count.Should().Be(1);
|
||||||
var slnProject = matchingProjects[0];
|
var slnProject = matchingProjects[0];
|
||||||
slnProject.FilePath.Should().Be(normalizedProjectPath);
|
slnProject.FilePath.Should().Be(projectPath);
|
||||||
slnProject.TypeGuid.Should().Be(ProjectTypeGuids.CPSProjectTypeGuid);
|
slnProject.TypeGuid.Should().Be(ProjectTypeGuids.CPSProjectTypeGuid);
|
||||||
if (!string.IsNullOrEmpty(projectGuid))
|
if (!string.IsNullOrEmpty(projectGuid))
|
||||||
{
|
{
|
||||||
|
|
|
@ -163,10 +163,10 @@ Options:
|
||||||
[Fact]
|
[Fact]
|
||||||
public void WhenProjectReferencesArePresentInTheSolutionItListsThem()
|
public void WhenProjectReferencesArePresentInTheSolutionItListsThem()
|
||||||
{
|
{
|
||||||
const string OutputText = @"Project reference(s)
|
string OutputText = $@"Project reference(s)
|
||||||
--------------------
|
--------------------
|
||||||
App\App.csproj
|
{Path.Combine("App", "App.csproj")}
|
||||||
Lib\Lib.csproj";
|
{Path.Combine("Lib", "Lib.csproj")}";
|
||||||
|
|
||||||
var projectDirectory = TestAssets
|
var projectDirectory = TestAssets
|
||||||
.Get("TestAppWithSlnAndExistingCsprojReferences")
|
.Get("TestAppWithSlnAndExistingCsprojReferences")
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
// 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 FluentAssertions;
|
||||||
|
using Microsoft.DotNet.Cli.Sln.Internal;
|
||||||
|
using Microsoft.DotNet.TestFramework;
|
||||||
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Migration.Tests
|
||||||
|
{
|
||||||
|
public class GivenThatIWantToMigrateSolutions : TestBase
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void ItMigratesAndBuildsSln()
|
||||||
|
{
|
||||||
|
MigrateAndBuild(
|
||||||
|
"NonRestoredTestProjects",
|
||||||
|
"PJAppWithSlnAndXprojRefs",
|
||||||
|
ProjectTypeGuids.CSharpProjectTypeGuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void WhenDirectoryAlreadyContainsCsprojFileItMigratesAndBuildsSln()
|
||||||
|
{
|
||||||
|
MigrateAndBuild(
|
||||||
|
"NonRestoredTestProjects",
|
||||||
|
"PJAppWithSlnAndXprojRefsAndUnrelatedCsproj",
|
||||||
|
ProjectTypeGuids.CSharpProjectTypeGuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void WhenXprojReferencesCsprojAndSlnDoesNotItMigratesAndBuildsSln()
|
||||||
|
{
|
||||||
|
MigrateAndBuild(
|
||||||
|
"NonRestoredTestProjects",
|
||||||
|
"PJAppWithSlnAndXprojRefThatRefsCsprojWhereSlnDoesNotRefCsproj",
|
||||||
|
ProjectTypeGuids.CPSProjectTypeGuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MigrateAndBuild(string groupName, string projectName, string subdirProjectTypeGuid)
|
||||||
|
{
|
||||||
|
var projectDirectory = TestAssets
|
||||||
|
.Get(groupName, projectName)
|
||||||
|
.CreateInstance()
|
||||||
|
.WithSourceFiles()
|
||||||
|
.Root;
|
||||||
|
|
||||||
|
var solutionRelPath = Path.Combine("TestApp", "TestApp.sln");
|
||||||
|
|
||||||
|
new DotnetCommand()
|
||||||
|
.WithWorkingDirectory(projectDirectory)
|
||||||
|
.Execute($"migrate \"{solutionRelPath}\"")
|
||||||
|
.Should().Pass();
|
||||||
|
|
||||||
|
new DotnetCommand()
|
||||||
|
.WithWorkingDirectory(projectDirectory)
|
||||||
|
.Execute($"restore \"{Path.Combine("TestApp", "TestApp.csproj")}\"")
|
||||||
|
.Should().Pass();
|
||||||
|
|
||||||
|
new DotnetCommand()
|
||||||
|
.WithWorkingDirectory(projectDirectory)
|
||||||
|
.Execute($"build \"{solutionRelPath}\"")
|
||||||
|
.Should().Pass();
|
||||||
|
|
||||||
|
SlnFile slnFile = SlnFile.Read(Path.Combine(projectDirectory.FullName, solutionRelPath));
|
||||||
|
slnFile.Projects.Count.Should().Be(3);
|
||||||
|
|
||||||
|
var slnProject = slnFile.Projects.Where((p) => p.Name == "TestApp").Single();
|
||||||
|
slnProject.TypeGuid.Should().Be(ProjectTypeGuids.CSharpProjectTypeGuid);
|
||||||
|
slnProject.FilePath.Should().Be("TestApp.csproj");
|
||||||
|
|
||||||
|
slnProject = slnFile.Projects.Where((p) => p.Name == "TestLibrary").Single();
|
||||||
|
slnProject.TypeGuid.Should().Be(ProjectTypeGuids.CSharpProjectTypeGuid);
|
||||||
|
slnProject.FilePath.Should().Be(Path.Combine("..", "TestLibrary", "TestLibrary.csproj"));
|
||||||
|
|
||||||
|
slnProject = slnFile.Projects.Where((p) => p.Name == "subdir").Single();
|
||||||
|
slnProject.TypeGuid.Should().Be(subdirProjectTypeGuid);
|
||||||
|
slnProject.FilePath.Should().Be(Path.Combine("src", "subdir", "subdir.csproj"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,7 @@
|
||||||
using Microsoft.Build.Construction;
|
// 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 Microsoft.Build.Construction;
|
||||||
using Microsoft.DotNet.TestFramework;
|
using Microsoft.DotNet.TestFramework;
|
||||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||||
using System;
|
using System;
|
||||||
|
@ -492,25 +495,6 @@ namespace Microsoft.DotNet.Migration.Tests
|
||||||
File.ReadAllText(migrationOutputFile).Should().Contain("MIGRATE1018");
|
File.ReadAllText(migrationOutputFile).Should().Contain("MIGRATE1018");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void ItMigratesSln()
|
|
||||||
{
|
|
||||||
var rootDirectory = TestAssetsManager.CreateTestInstance(
|
|
||||||
"TestAppWithSlnAndMultipleProjects",
|
|
||||||
callingMethod: "a").Path;
|
|
||||||
|
|
||||||
var testAppProjectDirectory = Path.Combine(rootDirectory, "TestApp");
|
|
||||||
var testLibProjectDirectory = Path.Combine(rootDirectory, "TestLibrary");
|
|
||||||
string slnPath = Path.Combine(testAppProjectDirectory, "TestApp.sln");
|
|
||||||
|
|
||||||
CleanBinObj(testAppProjectDirectory);
|
|
||||||
CleanBinObj(testLibProjectDirectory);
|
|
||||||
|
|
||||||
MigrateProject(slnPath);
|
|
||||||
Restore(testAppProjectDirectory, "TestApp.csproj");
|
|
||||||
BuildMSBuild(testAppProjectDirectory, "TestApp.sln", "Release");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void VerifyAutoInjectedDesktopReferences(string projectDirectory, string projectName, bool shouldBePresent)
|
private void VerifyAutoInjectedDesktopReferences(string projectDirectory, string projectName, bool shouldBePresent)
|
||||||
{
|
{
|
||||||
if (projectName != null)
|
if (projectName != null)
|
||||||
|
|
|
@ -204,16 +204,15 @@ Additional Arguments:
|
||||||
slnFile.Projects.Count.Should().Be(2);
|
slnFile.Projects.Count.Should().Be(2);
|
||||||
|
|
||||||
var projectToRemove = Path.Combine("Lib", "Lib.csproj");
|
var projectToRemove = Path.Combine("Lib", "Lib.csproj");
|
||||||
var projectToRemoveNormalized = @"Lib\Lib.csproj";
|
|
||||||
var cmd = new DotnetCommand()
|
var cmd = new DotnetCommand()
|
||||||
.WithWorkingDirectory(projectDirectory)
|
.WithWorkingDirectory(projectDirectory)
|
||||||
.ExecuteWithCapturedOutput($"remove project {projectToRemove}");
|
.ExecuteWithCapturedOutput($"remove project {projectToRemove}");
|
||||||
cmd.Should().Pass();
|
cmd.Should().Pass();
|
||||||
cmd.StdOut.Should().Be($"Project reference `{projectToRemoveNormalized}` removed.");
|
cmd.StdOut.Should().Be($"Project reference `{projectToRemove}` removed.");
|
||||||
|
|
||||||
slnFile = SlnFile.Read(solutionPath);
|
slnFile = SlnFile.Read(solutionPath);
|
||||||
slnFile.Projects.Count.Should().Be(1);
|
slnFile.Projects.Count.Should().Be(1);
|
||||||
slnFile.Projects[0].FilePath.Should().Be(@"App\App.csproj");
|
slnFile.Projects[0].FilePath.Should().Be(Path.Combine("App", "App.csproj"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -231,19 +230,18 @@ Additional Arguments:
|
||||||
slnFile.Projects.Count.Should().Be(3);
|
slnFile.Projects.Count.Should().Be(3);
|
||||||
|
|
||||||
var projectToRemove = Path.Combine("Lib", "Lib.csproj");
|
var projectToRemove = Path.Combine("Lib", "Lib.csproj");
|
||||||
var projectToRemoveNormalized = @"Lib\Lib.csproj";
|
|
||||||
var cmd = new DotnetCommand()
|
var cmd = new DotnetCommand()
|
||||||
.WithWorkingDirectory(projectDirectory)
|
.WithWorkingDirectory(projectDirectory)
|
||||||
.ExecuteWithCapturedOutput($"remove project {projectToRemove}");
|
.ExecuteWithCapturedOutput($"remove project {projectToRemove}");
|
||||||
cmd.Should().Pass();
|
cmd.Should().Pass();
|
||||||
|
|
||||||
string outputText = $@"Project reference `{projectToRemoveNormalized}` removed.
|
string outputText = $@"Project reference `{projectToRemove}` removed.
|
||||||
Project reference `{projectToRemoveNormalized}` removed.";
|
Project reference `{projectToRemove}` removed.";
|
||||||
cmd.StdOut.Should().Be(outputText);
|
cmd.StdOut.Should().Be(outputText);
|
||||||
|
|
||||||
slnFile = SlnFile.Read(solutionPath);
|
slnFile = SlnFile.Read(solutionPath);
|
||||||
slnFile.Projects.Count.Should().Be(1);
|
slnFile.Projects.Count.Should().Be(1);
|
||||||
slnFile.Projects[0].FilePath.Should().Be(@"App\App.csproj");
|
slnFile.Projects[0].FilePath.Should().Be(Path.Combine("App", "App.csproj"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -261,20 +259,19 @@ Project reference `{projectToRemoveNormalized}` removed.";
|
||||||
slnFile.Projects.Count.Should().Be(2);
|
slnFile.Projects.Count.Should().Be(2);
|
||||||
|
|
||||||
var projectToRemove = Path.Combine("Lib", "Lib.csproj");
|
var projectToRemove = Path.Combine("Lib", "Lib.csproj");
|
||||||
var projectToRemoveNormalized = @"Lib\Lib.csproj";
|
|
||||||
var cmd = new DotnetCommand()
|
var cmd = new DotnetCommand()
|
||||||
.WithWorkingDirectory(projectDirectory)
|
.WithWorkingDirectory(projectDirectory)
|
||||||
.ExecuteWithCapturedOutput($"remove project idontexist.csproj {projectToRemove} idontexisteither.csproj");
|
.ExecuteWithCapturedOutput($"remove project idontexist.csproj {projectToRemove} idontexisteither.csproj");
|
||||||
cmd.Should().Pass();
|
cmd.Should().Pass();
|
||||||
|
|
||||||
string outputText = $@"Project reference `idontexist.csproj` could not be found.
|
string outputText = $@"Project reference `idontexist.csproj` could not be found.
|
||||||
Project reference `{projectToRemoveNormalized}` removed.
|
Project reference `{projectToRemove}` removed.
|
||||||
Project reference `idontexisteither.csproj` could not be found.";
|
Project reference `idontexisteither.csproj` could not be found.";
|
||||||
cmd.StdOut.Should().Be(outputText);
|
cmd.StdOut.Should().Be(outputText);
|
||||||
|
|
||||||
slnFile = SlnFile.Read(solutionPath);
|
slnFile = SlnFile.Read(solutionPath);
|
||||||
slnFile.Projects.Count.Should().Be(1);
|
slnFile.Projects.Count.Should().Be(1);
|
||||||
slnFile.Projects[0].FilePath.Should().Be(@"App\App.csproj");
|
slnFile.Projects[0].FilePath.Should().Be(Path.Combine("App", "App.csproj"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue