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

Commit

Permalink
Merge pull request #397 from KSchlobohm/kschlobohm/keep_winforms_imports
Browse files Browse the repository at this point in the history
  • Loading branch information
cartermp authored Apr 28, 2021
2 parents 18e1645 + 3353dcc commit 602fba4
Show file tree
Hide file tree
Showing 39 changed files with 206 additions and 1,282 deletions.
13 changes: 8 additions & 5 deletions src/MSBuild.Abstractions/ProjectItemHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ public static bool IsSpecificPacakgeReference(ProjectItemElement element, string
/// Checks if a given item needs to be removed because it either only runs on desktop .NET or is automatically pulled in as a reference and is thus unnecessary.
/// </summary>
public static bool DesktopReferencesNeedsRemoval(ProjectItemElement item) =>
DesktopFacts.ReferencesThatNeedRemoval.Contains(item.Include, StringComparer.OrdinalIgnoreCase)
|| DesktopFacts.KnownWPFReferences.Contains(item.Include, StringComparer.OrdinalIgnoreCase)
|| DesktopFacts.KnownWinFormsReferences.Contains(item.Include, StringComparer.OrdinalIgnoreCase)
|| DesktopFacts.KnownDesktopReferences.Contains(item.Include, StringComparer.OrdinalIgnoreCase);
!(item.ElementName.Equals("import", StringComparison.OrdinalIgnoreCase)
&& !string.IsNullOrWhiteSpace(item.Include))
&& (DesktopFacts.ReferencesThatNeedRemoval.Contains(item.Include, StringComparer.OrdinalIgnoreCase)
|| DesktopFacts.KnownWPFReferences.Contains(item.Include, StringComparer.OrdinalIgnoreCase)
|| DesktopFacts.KnownWinFormsReferences.Contains(item.Include, StringComparer.OrdinalIgnoreCase)
|| DesktopFacts.KnownDesktopReferences.Contains(item.Include, StringComparer.OrdinalIgnoreCase));

/// <summary>
/// Checks if a given item is a desktop item that is globbed, so long as the metadata is a form type.
Expand All @@ -48,7 +50,8 @@ public static bool IsDesktopRemovableGlobbedItem(ProjectStyle style, ProjectItem
/// Checks if a given item is a well-known reference that can be converted to PackageReference.
/// </summary>
public static bool IsReferenceConvertibleToPackageReference(ProjectItemElement item) =>
MSBuildFacts.DefaultItemsThatHavePackageEquivalents.ContainsKey(item.Include);
!item.ElementName.Equals("import", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrWhiteSpace(item.Include)
&& MSBuildFacts.DefaultItemsThatHavePackageEquivalents.ContainsKey(item.Include);

/// <summary>
/// Checks if a reference is coming from an old-stlye NuGet package.
Expand Down
10 changes: 7 additions & 3 deletions src/MSBuild.Conversion.SDK/TargetFrameworkHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Text.Json;
using System.Text.RegularExpressions;

using Microsoft.Build.Locator;
using MSBuild.Conversion.Facts;
using NuGet.Versioning;

Expand All @@ -16,13 +15,18 @@ public static class TargetFrameworkHelper
/// <summary>
/// Determine the TFM to use based on what is installed on the users machine
/// </summary>
public static string FindHighestInstalledTargetFramework(bool usePreviewSDK)
public static string FindHighestInstalledTargetFramework(bool usePreviewSDK, string msbuildPath)
{
// Finds SDK path
string? sdkPath = null;
try
{
sdkPath = Path.GetFullPath(Path.Combine(MSBuildLocator.QueryVisualStudioInstances().Single().VisualStudioRootPath, "..", ".."));
if (string.IsNullOrWhiteSpace(msbuildPath))
{
throw new InvalidOperationException("msbuildPath is rquired");
}

sdkPath = Path.GetFullPath(Path.Combine(msbuildPath, "..", ".."));
}
catch (Exception)
{
Expand Down
2 changes: 1 addition & 1 deletion src/try-convert/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static int Run(string? project, string? workspace, string? msbuildPath, s
}
else
{
tfm = TargetFrameworkHelper.FindHighestInstalledTargetFramework(preview);
tfm = TargetFrameworkHelper.FindHighestInstalledTargetFramework(preview, msbuildPath);
}

var workspacePath = string.Empty;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.*" />
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
Expand Down
9 changes: 0 additions & 9 deletions tests/TestData/SmokeTests.MSTestVbNet5Baseline/UnitTest1.vb

This file was deleted.

This file was deleted.

Loading

0 comments on commit 602fba4

Please sign in to comment.