Skip to content

Commit 48dde8e

Browse files
ianrathboneadvay26lyndaidaii
authored
Add instructions to install MSBuildSdk packages (#9268)
* 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 <[email protected]> Co-authored-by: lyndaidaii <[email protected]>
1 parent d1b6b4c commit 48dde8e

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/NuGetGallery/Helpers/ViewModelExtensions/DisplayPackageViewModelFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ private DisplayPackageViewModel SetupInternal(
104104
// Lazily load the package types from the database.
105105
viewModel.IsDotnetToolPackageType = package.PackageTypes.Any(e => e.Name.Equals("DotnetTool", StringComparison.OrdinalIgnoreCase));
106106
viewModel.IsDotnetNewTemplatePackageType = package.PackageTypes.Any(e => e.Name.Equals("Template", StringComparison.OrdinalIgnoreCase));
107+
viewModel.IsMSBuildSdkPackageType = package.PackageTypes.Any(e => e.Name.Equals("MSBuildSdk", StringComparison.OrdinalIgnoreCase));
107108
}
108109

109110
if (packageKeyToDeprecation != null && packageKeyToDeprecation.TryGetValue(package.Key, out var deprecation))

src/NuGetGallery/ViewModels/DisplayPackageViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class DisplayPackageViewModel : ListPackageItemViewModel
3333

3434
public bool IsDotnetToolPackageType { get; set; }
3535
public bool IsDotnetNewTemplatePackageType { get; set; }
36+
public bool IsMSBuildSdkPackageType { get; set; }
3637
public bool IsAtomFeedEnabled { get; set; }
3738
public bool IsPackageDeprecationEnabled { get; set; }
3839
public bool IsPackageVulnerabilitiesEnabled { get; set; }

src/NuGetGallery/Views/Packages/DisplayPackage.cshtml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,21 @@
7878
}
7979
};
8080
}
81+
else if (Model.IsMSBuildSdkPackageType)
82+
{
83+
packageManagers = new PackageManagerViewModel[]
84+
{
85+
new PackageManagerViewModel("SDK")
86+
{
87+
Id = "sdk",
88+
InstallPackageCommands = new [] { string.Format("<Sdk Name=\"{0}\" Version=\"{1}\" />",
89+
Model.Id, Model.Version) },
90+
AlertLevel = AlertLevel.Info,
91+
AlertMessage = string.Format("For projects that support Sdk, copy this XML node into the project file to reference the package."),
92+
CopyLabel = "Copy the SDK XML node",
93+
}
94+
};
95+
}
8196
else
8297
{
8398
packageManagers = new PackageManagerViewModel[]

0 commit comments

Comments
 (0)