Skip to content

Commit

Permalink
Added "IsMSBuildSdkPackageType" to determine whether a package is of …
Browse files Browse the repository at this point in the history
…type MSBuildSdk.

DisplayPackage view modified to show specific instructions for SDK types in project files as per NuGet#8800
  • Loading branch information
ianrathbone committed Oct 3, 2022
1 parent 94499fd commit 41dbe39
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ private DisplayPackageViewModel SetupInternal(
// Lazily load the package types from the database.
viewModel.IsDotnetToolPackageType = package.PackageTypes.Any(e => e.Name.Equals("DotnetTool", StringComparison.OrdinalIgnoreCase));
viewModel.IsDotnetNewTemplatePackageType = package.PackageTypes.Any(e => e.Name.Equals("Template", StringComparison.OrdinalIgnoreCase));
viewModel.IsMSBuildSdkPackageType = package.PackageTypes.Any(e => e.Name.Equals("MSBuildSdk", StringComparison.OrdinalIgnoreCase));
}

if (packageKeyToDeprecation != null && packageKeyToDeprecation.TryGetValue(package.Key, out var deprecation))
Expand Down
1 change: 1 addition & 0 deletions src/NuGetGallery/ViewModels/DisplayPackageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class DisplayPackageViewModel : ListPackageItemViewModel

public bool IsDotnetToolPackageType { get; set; }
public bool IsDotnetNewTemplatePackageType { get; set; }
public bool IsMSBuildSdkPackageType { get; set; }
public bool IsAtomFeedEnabled { get; set; }
public bool IsPackageDeprecationEnabled { get; set; }
public bool IsPackageVulnerabilitiesEnabled { get; set; }
Expand Down
15 changes: 15 additions & 0 deletions src/NuGetGallery/Views/Packages/DisplayPackage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@
}
};
}
else if (Model.IsMSBuildSdkPackageType)
{
packageManagers = new PackageManagerViewModel[]
{
new PackageManagerViewModel("SDK")
{
Id = "sdk",
InstallPackageCommands = new [] { string.Format("<Sdk Include=\"{0}\" Version=\"{1}\" />",
Model.Id, Model.Version) },
AlertLevel = AlertLevel.Info,
AlertMessage = string.Format("For projects that support Sdk, copy this XML node into the project file to reference the package."),
CopyLabel = "Copy the SDK XML node",
}
};
}
else
{
packageManagers = new PackageManagerViewModel[]
Expand Down

0 comments on commit 41dbe39

Please sign in to comment.