Skip to content

Commit

Permalink
Add instructions to install MSBuildSdk packages (#9268)
Browse files Browse the repository at this point in the history
* Added "IsMSBuildSdkPackageType" to determine whether a package is of type MSBuildSdk.

DisplayPackage view modified to show specific instructions for SDK types in project files as per #8800

* Changed "Include" to correct attribute "Name" for SDK package type

Co-authored-by: Advay Tandon <82980589+advay26@users.noreply.github.com>
Co-authored-by: lyndaidaii <64443925+lyndaidaii@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 12, 2022
1 parent d1b6b4c commit 48dde8e
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 Name=\"{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 48dde8e

Please sign in to comment.