From a564efdcd4bf5f4ded0a0b490cabf0e3abc63a57 Mon Sep 17 00:00:00 2001 From: "C. Augusto Proiete" Date: Sat, 27 Feb 2021 20:56:19 -0400 Subject: [PATCH 1/4] Update wording for .NET CLI (Global) tools --- src/NuGetGallery/Views/Packages/DisplayPackage.cshtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NuGetGallery/Views/Packages/DisplayPackage.cshtml b/src/NuGetGallery/Views/Packages/DisplayPackage.cshtml index b134d7d6ef..7f7fc5808b 100644 --- a/src/NuGetGallery/Views/Packages/DisplayPackage.cshtml +++ b/src/NuGetGallery/Views/Packages/DisplayPackage.cshtml @@ -28,13 +28,13 @@ { packageManagers = new PackageManagerViewModel[] { - new PackageManagerViewModel(".NET CLI") + new PackageManagerViewModel(".NET CLI (Global)") { Id = "dotnet-cli", CommandPrefix = "> ", InstallPackageCommand = string.Format("dotnet tool install --global {0} --version {1}", Model.Id, Model.Version), AlertLevel = AlertLevel.Info, - AlertMessage = "This package contains a .NET Core Global Tool you can call from the shell/command line.", + AlertMessage = "This package contains a .NET tool you can call from the shell/command line.", }, new ThirdPartyPackageManagerViewModel("Cake", "https://cakebuild.net/support/nuget") From 1819c087d9cfe214c31bd7582516524c7185e5f8 Mon Sep 17 00:00:00 2001 From: "C. Augusto Proiete" Date: Sat, 27 Feb 2021 21:29:41 -0400 Subject: [PATCH 2/4] Add .NET local tool installation instructions --- .../Views/Packages/DisplayPackage.cshtml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/NuGetGallery/Views/Packages/DisplayPackage.cshtml b/src/NuGetGallery/Views/Packages/DisplayPackage.cshtml index 7f7fc5808b..850b57b3fa 100644 --- a/src/NuGetGallery/Views/Packages/DisplayPackage.cshtml +++ b/src/NuGetGallery/Views/Packages/DisplayPackage.cshtml @@ -30,13 +30,26 @@ { new PackageManagerViewModel(".NET CLI (Global)") { - Id = "dotnet-cli", + Id = "dotnet-cli-global", CommandPrefix = "> ", InstallPackageCommand = string.Format("dotnet tool install --global {0} --version {1}", Model.Id, Model.Version), AlertLevel = AlertLevel.Info, AlertMessage = "This package contains a .NET tool you can call from the shell/command line.", }, + new PackageManagerViewModel(".NET CLI (Local)") + { + Id = "dotnet-cli-local", + CommandPrefix = "> ", + InstallPackageCommand = string.Join + (Environment.NewLine, + "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 .NET tool you can call from the shell/command line.", + }, + new ThirdPartyPackageManagerViewModel("Cake", "https://cakebuild.net/support/nuget") { Id = "cake-dotnet-tool", From c000338a6ad0838cee075fa2d2a4f8cbfd7f5de3 Mon Sep 17 00:00:00 2001 From: "C. Augusto Proiete" Date: Sun, 21 Mar 2021 18:23:35 -0300 Subject: [PATCH 3/4] Add multi-line support for install instruction commands Co-authored-by: Joel Verhagen --- .../ViewModels/PackageManagerViewModel.cs | 4 +- .../Views/Packages/DisplayPackage.cshtml | 37 ++++++++++--------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/NuGetGallery/ViewModels/PackageManagerViewModel.cs b/src/NuGetGallery/ViewModels/PackageManagerViewModel.cs index 54f5522338..d4f68ef6b5 100644 --- a/src/NuGetGallery/ViewModels/PackageManagerViewModel.cs +++ b/src/NuGetGallery/ViewModels/PackageManagerViewModel.cs @@ -30,9 +30,9 @@ public PackageManagerViewModel(string name) public string CommandPrefix { get; set; } /// - /// A string that represents the command used to install a specific package. + /// One or more strings that represent the command(s) used to install a specific package. /// - public string InstallPackageCommand { get; set; } + public string[] InstallPackageCommands { get; set; } /// /// The alert message that contains clarifications about the command/scenario diff --git a/src/NuGetGallery/Views/Packages/DisplayPackage.cshtml b/src/NuGetGallery/Views/Packages/DisplayPackage.cshtml index 850b57b3fa..efb5d216cb 100644 --- a/src/NuGetGallery/Views/Packages/DisplayPackage.cshtml +++ b/src/NuGetGallery/Views/Packages/DisplayPackage.cshtml @@ -32,7 +32,7 @@ { Id = "dotnet-cli-global", CommandPrefix = "> ", - InstallPackageCommand = string.Format("dotnet tool install --global {0} --version {1}", Model.Id, Model.Version), + InstallPackageCommands = new [] { string.Format("dotnet tool install --global {0} --version {1}", Model.Id, Model.Version) }, AlertLevel = AlertLevel.Info, AlertMessage = "This package contains a .NET tool you can call from the shell/command line.", }, @@ -41,11 +41,11 @@ { Id = "dotnet-cli-local", CommandPrefix = "> ", - InstallPackageCommand = string.Join - (Environment.NewLine, - "dotnet new tool-manifest # if you are setting up this repo", - string.Format(" dotnet tool install --local {0} --version {1}", Model.Id, Model.Version) - ), + 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 .NET tool you can call from the shell/command line.", }, @@ -53,7 +53,7 @@ new ThirdPartyPackageManagerViewModel("Cake", "https://cakebuild.net/support/nuget") { Id = "cake-dotnet-tool", - InstallPackageCommand = Model.GetCakeInstallPackageCommand(), + InstallPackageCommands = new [] { Model.GetCakeInstallPackageCommand() }, }, }; } @@ -65,7 +65,7 @@ { Id = "dotnet-cli", CommandPrefix = "> ", - InstallPackageCommand = string.Format("dotnet new --install {0}::{1}", Model.Id, Model.Version), + InstallPackageCommands = new [] { string.Format("dotnet new --install {0}::{1}", Model.Id, Model.Version) }, AlertLevel = AlertLevel.Info, AlertMessage = "This package contains a .NET Core Template Package you can call from the shell/command line.", } @@ -79,26 +79,26 @@ { Id = "package-manager", CommandPrefix = "PM> ", - InstallPackageCommand = string.Format("Install-Package {0} -Version {1}", Model.Id, Model.Version) + InstallPackageCommands = new [] { string.Format("Install-Package {0} -Version {1}", Model.Id, Model.Version) }, }, new PackageManagerViewModel(".NET CLI") { Id = "dotnet-cli", CommandPrefix = "> ", - InstallPackageCommand = string.Format("dotnet add package {0} --version {1}", Model.Id, Model.Version) + InstallPackageCommands = new [] { string.Format("dotnet add package {0} --version {1}", Model.Id, Model.Version) }, }, new PackageManagerViewModel("PackageReference") { Id = "package-reference", - InstallPackageCommand = Model.DevelopmentDependency + InstallPackageCommands = new [] { Model.DevelopmentDependency ? string.Format(string.Join(Environment.NewLine, "", " all", " runtime; build; native; contentfiles; analyzers", ""), Model.Id, Model.Version) - : string.Format("", Model.Id, Model.Version), + : string.Format("", Model.Id, Model.Version) }, AlertLevel = AlertLevel.Info, AlertMessage = string.Format("For projects that support PackageReference, 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"), @@ -109,14 +109,14 @@ { Id = "paket-cli", CommandPrefix = "> ", - InstallPackageCommand = string.Format("paket add {0} --version {1}", Model.Id, Model.Version), + InstallPackageCommands = new [] { string.Format("paket add {0} --version {1}", Model.Id, Model.Version) }, }, new PackageManagerViewModel("F# Interactive") { Id = "fsharp-interactive", CommandPrefix = "> ", - InstallPackageCommand = string.Format("#r \"nuget: {0}, {1}\"", Model.Id, Model.Version), + InstallPackageCommands = new [] { string.Format("#r \"nuget: {0}, {1}\"", Model.Id, Model.Version) }, AlertLevel = AlertLevel.Info, AlertMessage = string.Format( "For F# scripts that support #r syntax, copy this into the source code to reference the package.", @@ -126,7 +126,7 @@ new ThirdPartyPackageManagerViewModel("Cake", "https://cakebuild.net/support/nuget") { Id = Model.IsCakeExtension() ? "cake-extension" : "cake", - InstallPackageCommand = Model.GetCakeInstallPackageCommand() + InstallPackageCommands = new [] { Model.GetCakeInstallPackageCommand() }, }, }; } @@ -178,11 +178,12 @@ @helper CommandPanel(PackageManagerViewModel packageManager, bool active) { var thirdPartyPackageManager = packageManager as ThirdPartyPackageManagerViewModel; -
-
@packageManager.InstallPackageCommand
+ @* Writing out the install command must be on a single line to avoid undesired whitespace in the
 tag. *@
+                @{ var cs = packageManager.InstallPackageCommands; }
+                
@foreach (var c in cs) {@(c + Environment.NewLine)}