
This commit ensures the correct property (`ProjectTypeGuids`) is respected when adding a project to a solution file. Additionally, we now error if a project type GUID cannot be determined rather than incorrectly mapping to the C# project type. Enabled previously disabled tests that were waiting on upstream changes from MSBuild and F#. Fixes #5131. Fixes #7742.
23 lines
837 B
C#
23 lines
837 B
C#
// 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.Collections.Generic;
|
|
using System.Linq;
|
|
using Microsoft.Build.Construction;
|
|
|
|
namespace Microsoft.DotNet.Tools.Common
|
|
{
|
|
public static class ProjectRootElementExtensions
|
|
{
|
|
public static string GetProjectTypeGuid(this ProjectRootElement rootElement)
|
|
{
|
|
return rootElement
|
|
.Properties
|
|
.FirstOrDefault(p => string.Equals(p.Name, "ProjectTypeGuids", StringComparison.OrdinalIgnoreCase))
|
|
?.Value
|
|
.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
|
|
.LastOrDefault(g => !string.IsNullOrWhiteSpace(g));
|
|
}
|
|
}
|
|
}
|