Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Add instructions to install MSBuildSdk packages #8800

Closed
augustoproiete opened this issue Sep 11, 2021 · 1 comment
Closed

[Feature]: Add instructions to install MSBuildSdk packages #8800

augustoproiete opened this issue Sep 11, 2021 · 1 comment
Labels

Comments

@augustoproiete
Copy link
Contributor

Related Problem

Packages of type MSBuildSdk such as Microsoft.DotNet.PackageValidation are meant to be consumed using the <Sdk ... /> element.

However, the NuGet Gallery displays the installation instructions equivalent of Dependency type package:

image

The Elevator Pitch

Add specific instructions for installing packages of type MSBuildSdk that the user can copy/paste on their project:

image

Additional Context and Details

No response

@augustoproiete augustoproiete added the feature-request Customer feature request label Sep 11, 2021
@loic-sharma
Copy link
Contributor

Good idea! If anyone is interested in implementing this, this is where you'll want to add this:

if (Model.IsDotnetToolPackageType)
{
packageManagers = new PackageManagerViewModel[]
{
new PackageManagerViewModel(".NET CLI (Global)")
{
Id = "dotnet-cli-global",
CommandPrefix = "> ",
InstallPackageCommands = new [] { string.Format("dotnet tool install --global {0} --version {1}", Model.Id, Model.Version) },
AlertLevel = AlertLevel.Info,
AlertMessage = "This package contains a <a href='https://aka.ms/global-tools'>.NET tool</a> you can call from the shell/command line.",
},
new PackageManagerViewModel(".NET CLI (Local)")
{
Id = "dotnet-cli-local",
CommandPrefix = "> ",
InstallPackageCommands = new []
{
"dotnet new tool-manifest # if you are setting up this repo",
string.Format("dotnet tool install --local {0} --version {1}", Model.Id, Model.Version),
},
AlertLevel = AlertLevel.Info,
AlertMessage = "This package contains a <a href='https://aka.ms/global-tools'>.NET tool</a> you can call from the shell/command line.",
},
new ThirdPartyPackageManagerViewModel("Cake", "https://cakebuild.net/support/nuget")
{
Id = "cake-dotnet-tool",
InstallPackageCommands = new [] { Model.GetCakeInstallPackageCommand() },
},
new ThirdPartyPackageManagerViewModel("NUKE", "https://github.com/nuke-build/nuke/issues/new/choose")
{
Id = "nuke",
CommandPrefix = "> ",
InstallPackageCommands = new [] { string.Format("nuke :add-package {0} --version {1}", Model.Id, Model.Version) },
},
};
}
else if (Model.IsDotnetNewTemplatePackageType)
{
packageManagers = new PackageManagerViewModel[]
{
new PackageManagerViewModel(".NET CLI")
{
Id = "dotnet-cli",
CommandPrefix = "> ",
InstallPackageCommands = new [] { string.Format("dotnet new --install {0}::{1}", Model.Id, Model.Version) },
AlertLevel = AlertLevel.Info,
AlertMessage = "This package contains a <a href='https://aka.ms/dotnet-new'>.NET Core Template Package</a> you can call from the shell/command line.",
}
};
}
else
{
packageManagers = new PackageManagerViewModel[]
{
new PackageManagerViewModel("Package Manager")
{
Id = "package-manager",
CommandPrefix = "PM> ",
InstallPackageCommands = new [] { string.Format("Install-Package {0} -Version {1}", Model.Id, Model.Version) },
},
new PackageManagerViewModel(".NET CLI")
{
Id = "dotnet-cli",
CommandPrefix = "> ",
InstallPackageCommands = new [] { string.Format("dotnet add package {0} --version {1}", Model.Id, Model.Version) },
},
new PackageManagerViewModel("PackageReference")
{
Id = "package-reference",
InstallPackageCommands = new [] { Model.DevelopmentDependency
? string.Format(string.Join(Environment.NewLine,
"<PackageReference Include=\"{0}\" Version=\"{1}\">",
" <PrivateAssets>all</PrivateAssets>",
" <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>",
"</PackageReference>"), Model.Id, Model.Version)
: string.Format("<PackageReference Include=\"{0}\" Version=\"{1}\" />", Model.Id, Model.Version) },
AlertLevel = AlertLevel.Info,
AlertMessage = string.Format("For projects that support <a href=\"{0}\">PackageReference</a>, copy this XML node into the project file to reference the package.",
"https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files"),
CopyLabel = "Copy the PackageReference XML node",
},
new ThirdPartyPackageManagerViewModel("Paket CLI", "https://fsprojects.github.io/Paket/contact.html")
{
Id = "paket-cli",
CommandPrefix = "> ",
InstallPackageCommands = new [] { string.Format("paket add {0} --version {1}", Model.Id, Model.Version) },
},
new PackageManagerViewModel("Script & Interactive")
{
Id = "script-interactive",
CommandPrefix = "> ",
InstallPackageCommands = new [] { string.Format("#r \"nuget: {0}, {1}\"", Model.Id, Model.Version) },
AlertLevel = AlertLevel.Info,
AlertMessage = "#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package."
},
new ThirdPartyPackageManagerViewModel("Cake", "https://cakebuild.net/support/nuget")
{
Id = Model.IsCakeExtension() ? "cake-extension" : "cake",
InstallPackageCommands = new [] { Model.GetCakeInstallPackageCommand() },
},
};
}

And:

viewModel.IsDotnetToolPackageType = package.PackageTypes.Any(e => e.Name.Equals("DotnetTool", StringComparison.OrdinalIgnoreCase));
viewModel.IsDotnetNewTemplatePackageType = package.PackageTypes.Any(e => e.Name.Equals("Template", StringComparison.OrdinalIgnoreCase));

ianrathbone added a commit to ianrathbone/NuGetGallery that referenced this issue Oct 3, 2022
…type MSBuildSdk.

DisplayPackage view modified to show specific instructions for SDK types in project files as per NuGet#8800
applejax124 pushed a commit that referenced this issue Oct 12, 2022
* 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>
RiadGahlouz added a commit that referenced this issue Oct 19, 2022
* Update NuGetGallery.Services to address CG alerts (#9274)

* Address accessibility for syntax highlighting (#9273)

* address accessbility for syntax highlighting

* Fix Support link (#9276)

* fix broken support link

* Update Download table heading (#9267)

* update correct place

* update table header placement

* 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 <82980589+advay26@users.noreply.github.com>
Co-authored-by: lyndaidaii <64443925+lyndaidaii@users.noreply.github.com>

* [CodeQL] Suppress CSRF token validation warnings (#9278)

* Added CSRF token checks to address CodeQL bugs

* Added CodeQL suppressions

* Make thinner border for focused links (#9277)

* Make thiner border for focused links

* Change border size of package manager tabs

* Delete comment line from base.less

* Change nav-tabs color and make overflow-y visible for package-tags

Co-authored-by: Joel Verhagen <jver@microsoft.com>
Co-authored-by: lyndaidaii <64443925+lyndaidaii@users.noreply.github.com>
Co-authored-by: toseni <seniut.tomas@gmail.com>
Co-authored-by: Ian Rathbone <ian@rathbone.dev>
Co-authored-by: Advay Tandon <82980589+advay26@users.noreply.github.com>
Co-authored-by: Daniel Olczyk <44818681+MRmlik12@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants