Skip to content

Commit

Permalink
Add logic to support SSDT SDK project type guid (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saurabhfaujdar authored Nov 15, 2024
1 parent 5e1e280 commit eb5f73f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ public void GetProjectTypeGuidLegacyProject(string extension)
case ProjectFileExtensions.VisualBasic:
actualProject.ProjectTypeGuid.ShouldBe(new Guid("F184B08F-C81C-45F6-A57F-5ABD9991F28F"));
break;

case ProjectFileExtensions.SqlServerDb:
actualProject.ProjectTypeGuid.ShouldBe(new Guid("00D1A9C2-B5F0-4AF3-8072-F6C62B433612"));
break;
default:
actualProject.ProjectTypeGuid.ShouldBe(SlnProject.KnownProjectTypeGuids[extension]);
break;
Expand Down Expand Up @@ -148,6 +150,10 @@ public void GetProjectTypeGuidSdkProject(string extension)
actualProject.ProjectTypeGuid.ShouldBe(new Guid("778DAE3C-4631-46EA-AA77-85C1314464D9"));
break;

case ProjectFileExtensions.SqlServerDb:
actualProject.ProjectTypeGuid.ShouldBe(new Guid("42EA0DBD-9CF1-443E-919E-BE9C484E4577"));
break;

default:
actualProject.ProjectTypeGuid.ShouldBe(SlnProject.KnownProjectTypeGuids[extension]);
break;
Expand Down
16 changes: 16 additions & 0 deletions src/Microsoft.VisualStudio.SlnGen/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,22 @@ public static bool IsPropertyValueTrue(this Project project, string name)
return project.GetPropertyValue(name).Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase);
}

/// <summary>
/// Returns true if a property value exists else returns false.
/// </summary>
/// <param name = "project" > The < see cref="Project" /> to get the property of.</param>
/// <param name="name">The name of the property.</param>
/// <returns>if the property exists return true, otherwise false.</returns>
public static bool DoesPropertyExist(this Project project, string name)
{
if (project.GetPropertyValue(name).Equals(String.Empty))
{
return false;
}

return true;
}

/// <summary>
/// Splits the current string as a semicolon delimited list of equals sign separated key/value pairs.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/Microsoft.VisualStudio.SlnGen/MSBuildPropertyNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ public static class MSBuildPropertyNames
/// </summary>
public const string UsingMicrosoftNETSdk = nameof(UsingMicrosoftNETSdk);

/// <summary>
/// Represents the NETCoreTargetsPath property.
/// </summary>
public const string NETCoreTargetsPath = nameof(NETCoreTargetsPath);

/// <summary>
/// Represents the SlnGenIsBuildable property.
/// </summary>
Expand Down
19 changes: 15 additions & 4 deletions src/Microsoft.VisualStudio.SlnGen/SlnProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public sealed class SlnProject
[string.Empty] = DefaultLegacyProjectTypeGuid,
[ProjectFileExtensions.CSharp] = DefaultLegacyProjectTypeGuid,
[ProjectFileExtensions.VisualBasic] = new (VisualStudioProjectTypeGuids.LegacyVisualBasicProject),
[ProjectFileExtensions.SqlServerDb] = new (VisualStudioProjectTypeGuids.SqlServerDbProjectLegacy),
};

/// <summary>
Expand All @@ -45,6 +46,7 @@ public sealed class SlnProject
[string.Empty] = DefaultNetSdkProjectTypeGuid,
[ProjectFileExtensions.CSharp] = DefaultNetSdkProjectTypeGuid,
[ProjectFileExtensions.VisualBasic] = new (VisualStudioProjectTypeGuids.NetSdkVisualBasicProject),
[ProjectFileExtensions.SqlServerDb] = new (VisualStudioProjectTypeGuids.SqlServerDbProjectSdk),
};

/// <summary>
Expand All @@ -63,7 +65,6 @@ public sealed class SlnProject
[ProjectFileExtensions.NuProj] = new (VisualStudioProjectTypeGuids.NuProj),
[ProjectFileExtensions.Scope] = new (VisualStudioProjectTypeGuids.ScopeProject),
[ProjectFileExtensions.Shproj] = new (VisualStudioProjectTypeGuids.SharedProject),
[ProjectFileExtensions.SqlServerDb] = new (VisualStudioProjectTypeGuids.SqlServerDbProject),
[ProjectFileExtensions.VcxItems] = new (VisualStudioProjectTypeGuids.Cpp),
[ProjectFileExtensions.Wap] = new (VisualStudioProjectTypeGuids.WapProject),
[ProjectFileExtensions.Wix] = new (VisualStudioProjectTypeGuids.Wix),
Expand Down Expand Up @@ -160,6 +161,8 @@ public static SlnProject FromProject(Project project, IReadOnlyDictionary<string

bool isUsingMicrosoftNETSdk = project.IsPropertyValueTrue(MSBuildPropertyNames.UsingMicrosoftNETSdk);

bool isUsingMicrosoftSQLSdk = project.DoesPropertyExist("NETCoreTargetsPath");

string projectFileExtension = Path.GetExtension(fullPath);

bool isSharedProject = string.Equals(projectFileExtension, ProjectFileExtensions.Shproj, StringComparison.Ordinal) || string.Equals(projectFileExtension, ProjectFileExtensions.VcxItems, StringComparison.Ordinal);
Expand Down Expand Up @@ -191,7 +194,7 @@ public static SlnProject FromProject(Project project, IReadOnlyDictionary<string
Name = name,
Platforms = GetPlatforms(project, projectFileExtension, isUsingMicrosoftNETSdk),
ProjectGuid = GetProjectGuid(project, isUsingMicrosoftNETSdk),
ProjectTypeGuid = GetProjectTypeGuid(projectFileExtension, isUsingMicrosoftNETSdk, customProjectTypeGuids),
ProjectTypeGuid = GetProjectTypeGuid(projectFileExtension, isUsingMicrosoftNETSdk, customProjectTypeGuids, isUsingMicrosoftSQLSdk),
SharedProjectItems = sharedProjectItemPaths.Any() ? sharedProjectItemPaths : Array.Empty<string>(),
SolutionFolder = project.GetPropertyValueOrDefault(MSBuildPropertyNames.SlnGenSolutionFolder, string.Empty),
IsBuildable = isBuildable,
Expand Down Expand Up @@ -327,7 +330,7 @@ internal static Guid GetProjectGuid(Project project, bool isUsingMicrosoftNETSdk
/// <param name="isUsingMicrosoftNETSdk">A value indicating whether or not the specified project is using Microsoft.NET.Sdk.</param>
/// <param name="customProjectTypeGuids">An <see cref="IReadOnlyDictionary{String, Guid}" /> containing any user specified project type GUIDs to use.</param>
/// <returns>A <see cref="Guid" /> representing the project type of the specified project.</returns>
internal static Guid GetProjectTypeGuid(string projectFileExtension, bool isUsingMicrosoftNETSdk, IReadOnlyDictionary<string, Guid> customProjectTypeGuids)
internal static Guid GetProjectTypeGuid(string projectFileExtension, bool isUsingMicrosoftNETSdk, IReadOnlyDictionary<string, Guid> customProjectTypeGuids, bool isUsingMicrosoftSQLSdk)
{
if (customProjectTypeGuids.TryGetValue(projectFileExtension, out Guid projectTypeGuid) || KnownProjectTypeGuids.TryGetValue(projectFileExtension, out projectTypeGuid))
{
Expand All @@ -344,9 +347,17 @@ internal static Guid GetProjectTypeGuid(string projectFileExtension, bool isUsin
return projectTypeGuid;
}

if (isUsingMicrosoftSQLSdk)
{
if (KnownNetSdkProjectTypeGuids.TryGetValue(projectFileExtension, out projectTypeGuid))
{
return projectTypeGuid;
}
}

if (!KnownLegacyProjectTypeGuids.TryGetValue(projectFileExtension, out projectTypeGuid))
{
projectTypeGuid = DefaultLegacyProjectTypeGuid;
return projectTypeGuid = DefaultLegacyProjectTypeGuid;
}

return projectTypeGuid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ public static class VisualStudioProjectTypeGuids
/// <summary>
/// SQL Server database projects (.sqlproj).
/// </summary>
public const string SqlServerDbProject = "00D1A9C2-B5F0-4AF3-8072-F6C62B433612";
public const string SqlServerDbProjectLegacy = "00D1A9C2-B5F0-4AF3-8072-F6C62B433612";

/// <summary>
/// SQL Server database projects (.sqlproj).
/// </summary>
public const string SqlServerDbProjectSdk = "42EA0DBD-9CF1-443E-919E-BE9C484E4577";

/// <summary>
/// Windows Application Packaging projects (.wapproj).
Expand Down

0 comments on commit eb5f73f

Please sign in to comment.