From 612f0756444f404de7ce1c218e7f1e062e2c82b0 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sun, 3 Apr 2011 13:50:37 +0100 Subject: [PATCH] Show help in package management console. --- .../Project/PackageManagement.csproj | 8 + .../Scripting/PackageManagementConsoleHost.cs | 25 +- .../NuGet.Cmdlets.dll-Help.xml | 685 ++++++++++++++++++ .../about_NuGet.Cmdlets.help.txt | 39 + .../TestablePackageManagementConsoleHost.cs | 7 + .../PackageManagementConsoleHostTests.cs | 26 + 6 files changed, 789 insertions(+), 1 deletion(-) create mode 100644 src/AddIns/Misc/PackageManagement/RequiredLibraries/NuGet.Cmdlets.dll-Help.xml create mode 100644 src/AddIns/Misc/PackageManagement/RequiredLibraries/about_NuGet.Cmdlets.help.txt diff --git a/src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj b/src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj index 086350f4fb..4c4fa8dbef 100644 --- a/src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj +++ b/src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj @@ -227,10 +227,18 @@ + + about_NuGet.Cmdlets.help.txt + Always + NuGet-LICENSE.txt Always + + PackageManagement.Cmdlets.dll-Help.xml + Always + Always diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageManagementConsoleHost.cs b/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageManagementConsoleHost.cs index a9bf202143..1fa5c94cd2 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageManagementConsoleHost.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PackageManagementConsoleHost.cs @@ -103,12 +103,14 @@ namespace ICSharpCode.PackageManagement.Scripting void WriteInfoBeforeFirstPrompt() { WriteNuGetVersionInfo(); + WriteHelpInfo(); + WriteLine(); } void WriteNuGetVersionInfo() { string versionInfo = String.Format("NuGet {0}", GetNuGetVersion()); - ScriptingConsole.WriteLine(versionInfo, ScriptingStyle.Out); + WriteLine(versionInfo); } protected virtual Version GetNuGetVersion() @@ -120,6 +122,27 @@ namespace ICSharpCode.PackageManagement.Scripting return nuGetVersion; } + void WriteLine(string message) + { + ScriptingConsole.WriteLine(message, ScriptingStyle.Out); + } + + void WriteLine() + { + WriteLine(String.Empty); + } + + void WriteHelpInfo() + { + string helpInfo = GetHelpInfo(); + WriteLine(helpInfo); + } + + protected virtual string GetHelpInfo() + { + return "Type 'get-help NuGet' for more information."; + } + void WritePrompt() { ScriptingConsole.Write(prompt, ScriptingStyle.Prompt); diff --git a/src/AddIns/Misc/PackageManagement/RequiredLibraries/NuGet.Cmdlets.dll-Help.xml b/src/AddIns/Misc/PackageManagement/RequiredLibraries/NuGet.Cmdlets.dll-Help.xml new file mode 100644 index 0000000000..1c39096ff6 --- /dev/null +++ b/src/AddIns/Misc/PackageManagement/RequiredLibraries/NuGet.Cmdlets.dll-Help.xml @@ -0,0 +1,685 @@ + + + + + + + + + + Install-Package + + + Installs a package. + + + + + Install + Package + + + + + Installs a package and its dependencies into the project. + + + + + + Install-Package + + Id + string + + + IgnoreDependencies + + + ProjectName + string + + + Version + string + + + Source + string + + + + + + + + Id + + Specifies the package ID of the package to install. + + + string + + + + + + + + + IgnoreDependencies + + Installs only this package and not its dependencies. + + + + ProjectName + + Specifies the project to install the package into. If ommitted, the active project is chosen. + + + string + + + + Source + + Specifies the URL or directory path for the package source containing the package to install. If omitted, looks in the currently selected package source to find the corresponding package URL. + + + string + + + + Version + + Specifies the version of the package to install. If omitted, defaults to the latest version. + + + string + + + + + + + + + + Online version: + http://nuget.codeplex.com/ + + + Install-Package + + + + + + + + + + + Get-Package + + + Gets the set of packages available from the package source. Use the -ListAvailable flag to list packages available from the package source. + + + + + Get + Package + + + + + Gets the set of packages available from the package source. Defaults to only showing the list of installed packages. Use the -ListAvailable flag to list packages available from the package source. + + + + + + Get-Package + + Source + string + + + ListAvailable + + + Updates + + + Recent + + + Filter + string + + + First + int + + + Skip + int + + + + + + + + Source + + Specifies the URL or directory path for the package source containing the package to install. If omitted, looks in the currently selected package source to find the corresponding package URL. + + + string + + + + ListAvailable + + Gets packages available from the online package source. + + + + Recent + + Gets the list of recently installed packages. + + + + Updates + + Gets packages that have an update available from the package source. + + + + Filter + + Specifies a filter string used to narrow down the list of packages returned. The filter is searched for in the package Id and in the description. + + + + First + + Specifies the number of packages to return from the beginning of the list. + + + + Skip + + Skips (does not return) the specified number of packages, counting from the beginning of the list. + + + + + + + + Online version: + http://nuget.codeplex.com + + + Get-Package + + + + + + + + + + + Uninstall-Package + + + Uninstalls a package. + + + + + Uninstall + Package + + + + + Uninstalls a package. If other packages depend on this package, the command will fail unless the –Force option is specified. + + + + + + Uninstall-Package + + Id + string + + + RemoveDependencies + + + Force + + + Version + string + + + + + + + + + Id + + Specifies the package ID of the package to uninstall. + + + string + + + + + + + + + RemoveDependencies + + Uninstalls the package and its unused dependencies. + + + + ProjectName + + Specifies the project to uninstall the package from. If ommitted, the default project is chosen. + + + string + + + + Version + + The version of the package to uninstall. If omitted, defaults to the latest version. + + + string + + + + + + + + + Online version: + http://nuget.codeplex.com + + + Uninstall-Package + + + + + + + + + + + Update-Package + + + Updates a package. + + + + + Update + Package + + + + + Updates a package and its dependencies to a newer version. + + + + + + Update-Package + + Id + string + + + IgnoreDependencies + + + ProjectName + string + + + Version + string + + + Source + string + + + + + + + + Id + + Specifies the package ID of the package to update. + + + string + + + + + + + + + IgnoreDependencies + + Updates all of the package’s dependencies to the latest version. False by default. + + + + ProjectName + + Specifies the project containing the project to update. If ommitted, the default project is chosen. + + + string + + + + Source + + Specifies the URL or directory path for the package source containing the package to install. If omitted, looks in the currently selected package source to find the corresponding package URL. + + + string + + + + Version + + Specifies the version that the package will be upgraded to. If omitted, defaults to the latest version. + + + string + + + + + + + + + Online version: + http://nuget.codeplex.com/ + + + Update-Package + + + + + + + + + + + New-Package + + + Creates a package. + + + + + New + Package + + + + + Creates a new package when supplied with a Nuspec package specification file. + + + + + + New-Package + + ProjectName + string + + + SpecFileName + string + + + TargetFile + string + + + NoClobber + + + + + + + + ProjectName + + Specifies the project containing the NuSpec file to use when creating the package. If omitted, the current project selected in the console is used. + + string + + + SpecFileName + + Specifies the NuSpec file used to create the package. If omitted, the NuSpec file within the current project is used if there is only one such file. + + string + + + TargetFile + + Specifes the full name of the output NuPkg file. + + string + + + NoClobber + + If specified, the target file is not overwritten. + + + + + + + + Online version: + http://nuget.codeplex.com + + + New-Package + + + + + + + + + + + Add-BindingRedirect + + + Adds binding redirects to the config file. + + + + + Add + BindingRedirect + + + + + Examines all assemblies within the output path for a project and adds binding redirects to the application (or web) configuration file where necessary. + + + + + + Add-BindingRedirect + + ProjectName + string + + + + + + + + + ProjectName + + Specifies the project to analyze and add binding redirects to. + + + string + + + + + + + + Online version: + http://nuget.codeplex.com + + + Add-BindingRedirect + + + + + + + + + + + Get-Project + + + Gets the active or specified project. + + + + + Get + Project + + + + + Returns a reference to the DTE (Development Tools Environment) for the active or specified project. + + + + + + Get-Project + + Name + string + + + All + + + + + + + + + Name + + Specifies the project to return. If ommitted, the active project is returned. + + + string + + + + All + + Returns every project in the solution. + + + + + + + + Online version: + http://nuget.codeplex.com + + + Get-Project + + + + + \ No newline at end of file diff --git a/src/AddIns/Misc/PackageManagement/RequiredLibraries/about_NuGet.Cmdlets.help.txt b/src/AddIns/Misc/PackageManagement/RequiredLibraries/about_NuGet.Cmdlets.help.txt new file mode 100644 index 0000000000..b56a7920ee --- /dev/null +++ b/src/AddIns/Misc/PackageManagement/RequiredLibraries/about_NuGet.Cmdlets.help.txt @@ -0,0 +1,39 @@ +TOPIC + about_NuGet + +SHORT DESCRIPTION + Provides information about NuGet Package Manager commands. + +LONG DESCRIPTION + This topic describes the NuGet Package Manager commands. NuGet is an integrated package + management tool for adding libraries and tools to .NET projects. + + + The following NuGet cmdlets are included. + + Cmdlet Description + ------------------ ---------------------------------------------- + Get-Package Gets the set of packages available from the package source. + + Install-Package Installs a package and its dependencies into the project. + + Uninstall-Package Uninstalls a package. If other packages depend on this package, + the command will fail unless the –Force option is specified. + + Update-Package Updates a package and its dependencies to a newer version. + + New-Package Creates a new package when supplied with a Nuspec package specification file. + + Add-BindingRedirect Examines all assemblies within the output path for a project and adds binding + redirects to the application (or web) configuration file where necessary. + + Get-Project Returns a reference to the DTE (Development Tools Environment) for the active + or specified project. + +SEE ALSO + Online documentation: http://go.microsoft.com/fwlink/?LinkID=206619 + Get-Package + Install-Package + Uninstall-Package + Update-Package + New-Package diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/TestablePackageManagementConsoleHost.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/TestablePackageManagementConsoleHost.cs index 41381650d4..13214a1c9b 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/TestablePackageManagementConsoleHost.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/Helpers/TestablePackageManagementConsoleHost.cs @@ -48,5 +48,12 @@ namespace PackageManagement.Tests.Helpers { return VersionToReturnFromGetNuGetVersion; } + + public string TextToReturnFromGetHelpInfo = String.Empty; + + protected override string GetHelpInfo() + { + return TextToReturnFromGetHelpInfo; + } } } diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageManagementConsoleHostTests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageManagementConsoleHostTests.cs index 645f896c86..cc40156452 100644 --- a/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageManagementConsoleHostTests.cs +++ b/src/AddIns/Misc/PackageManagement/Test/Src/Scripting/PackageManagementConsoleHostTests.cs @@ -215,5 +215,31 @@ namespace PackageManagement.Tests.Scripting Assert.IsTrue(contains); } + + [Test] + public void Run_TextDisplayedBeforeFirstPromptDisplayed_HelpInfoDisplayed() + { + CreateHost(); + string expectedHelpMessage = "Type 'get-help NuGet' for more information."; + host.TextToReturnFromGetHelpInfo = expectedHelpMessage; + RunHost(); + + bool contains = scriptingConsole.AllTextPassedToWriteLine.Contains("Type 'get-help NuGet' for more information."); + + Assert.IsTrue(contains); + } + + [Test] + public void Run_TextDisplayedBeforeFirstPromptDisplayed_BlankLineBeforePrompt() + { + CreateHost(); + host.TextToReturnFromGetHelpInfo = "abc"; + RunHost(); + + string actualLastLine = scriptingConsole.LastLinePassedToWriteLine; + string expectedLastLine = String.Empty; + + Assert.AreEqual(expectedLastLine, actualLastLine); + } } }