Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Fail conversion if we see System.Web #280

Merged
merged 2 commits into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/MSBuild.Abstractions/MSBuildHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,6 @@ public static bool ArePropertyGroupElementsIdentical(ProjectPropertyGroupElement
&& groupA.Properties.All(propA => groupB.Properties.Any(propB => ProjectPropertyHelpers.ArePropertiesEqual(propA, propB)));
}

/// <summary>
/// Checks if there is a reference to System.Web, which is unsupported on .NET Core, in the given project.
/// </summary>
public static bool IsProjectReferencingSystemWeb(MSBuildProjectRootElement root) => root.ItemGroups.Any(ig => ig.Items.Any(ProjectItemHelpers.IsReferencingSystemWeb));

/// <summary>
/// Unquote string. It simply removes the starting and ending "'", and checks they are present before.
/// </summary>
Expand Down
60 changes: 29 additions & 31 deletions src/MSBuild.Abstractions/MSBuildWorkspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,43 +237,40 @@ private bool IsSupportedProjectType(MSBuildProjectRootElement root)
}

// Lots of wild old project types have project type guids that the old project system uses to light things up!
if (MSBuildHelpers.HasProjectTypeGuidsNode(root))
// Also some references that are incompatible.
var projectType = GetProjectSupportType(root);
switch (projectType)
{
var projectType = GetProjectSupportType(root);
switch (projectType)
{
case ProjectSupportType.LegacyWeb:
Console.WriteLine($"'{root.FullPath}' is a legacy web project, which is unsupported by this tool.");
return false;
case ProjectSupportType.CodedUITest:
Console.WriteLine($"'{root.FullPath}' is a coded UI test. Coded UI tests are deprecated and not convertable to .NET Core.");
return false;
case ProjectSupportType.UnknownTestProject:
Console.WriteLine($"'{root.FullPath}' has invalid Project Type Guids for test projects and is not supported.");
return false;
case ProjectSupportType.UnsupportedTestType:
Console.WriteLine($"'{root.FullPath}' is an unsupported MSTest test type. Only Unit Tests are supported.");
return false;
case ProjectSupportType.Desktop:
case ProjectSupportType.MSTest:
// Let them know about System.Web while we're here
if (MSBuildHelpers.IsProjectReferencingSystemWeb(root))
{
Console.WriteLine($"'{root.FullPath}' references System.Web, which is unsupported on .NET Core. You may have significant work remaining after conversion.");
}
return true;
case ProjectSupportType.Unsupported:
default:
case ProjectSupportType.LegacyWeb:
Console.WriteLine($"'{root.FullPath}' is a legacy web project and/or reference System.Web. Legacy Web projects and System.Web are unsupported on .NET Core. You will need to rewrite your application or find a way to not depend on System.Web to convert this project.");
return false;
case ProjectSupportType.CodedUITest:
Console.WriteLine($"'{root.FullPath}' is a coded UI test. Coded UI tests are deprecated and not convertable to .NET Core.");
return false;
case ProjectSupportType.UnknownTestProject:
Console.WriteLine($"'{root.FullPath}' has invalid Project Type Guids for test projects and is not supported.");
return false;
case ProjectSupportType.UnsupportedTestType:
Console.WriteLine($"'{root.FullPath}' is an unsupported MSTest test type. Only Unit Tests are supported.");
return false;
case ProjectSupportType.Desktop:
case ProjectSupportType.MSTest:
return true;
case ProjectSupportType.Unsupported:
default:
cartermp marked this conversation as resolved.
Show resolved Hide resolved
if (MSBuildHelpers.HasProjectTypeGuidsNode(root))
{
var allSupportedProjectTypeGuids = DesktopFacts.KnownSupportedDesktopProjectTypeGuids.Select(ptg => ptg.ToString());
var allReadProjectTypeGuids = MSBuildHelpers.GetAllProjectTypeGuids(root);
Console.WriteLine($"{root.FullPath} is an unsupported project type. Not all project type guids are supported.");
PrintGuidMessage(allSupportedProjectTypeGuids, allReadProjectTypeGuids);
return false;
}
else
{
return true;
}
}
}

// assume its supported
return true;

static void PrintGuidMessage(IEnumerable<string> allSupportedProjectTypeGuids, IEnumerable<string> allReadProjectTypeGuids)
{
Expand All @@ -292,7 +289,8 @@ static void PrintGuidMessage(IEnumerable<string> allSupportedProjectTypeGuids, I

static ProjectSupportType GetProjectSupportType(MSBuildProjectRootElement root)
{
if (root.PropertyGroups.Any(pg => pg.Properties.Any(ProjectPropertyHelpers.IsLegacyWebProjectTypeGuidsProperty)))
if (root.PropertyGroups.Any(pg => pg.Properties.Any(ProjectPropertyHelpers.IsLegacyWebProjectTypeGuidsProperty))
|| root.ItemGroups.Any(ig => ig.Items.Any(ProjectItemHelpers.IsReferencingSystemWeb)))
{
return ProjectSupportType.LegacyWeb;
}
Expand Down