顯示具有 NuGet 標籤的文章。 顯示所有文章
顯示具有 NuGet 標籤的文章。 顯示所有文章

2013年5月25日 星期六

Package Visualizer

Package Visualizer can let you know what packages are using and how are their dependencies in between.

In the menu bar, TOOLS –> Library Package Manager –> Package Visualizer

image

By default, the output is Top to bottom

image

We can switch to Left to right

image

Available Commands in NuGet.CommandLine

NuGet Version: 2.5.40416.9020
usage: NuGet <command> [args] [options]
Type 'NuGet help <command>' for help on a specific command.

Available commands:

config      Gets or sets NuGet config values.
delete      Deletes a package from the server.
help (?)    Displays general help information and help information about other commands.
install     Installs a package using the specified sources. If no sources are specified, all sources defined in the NuGet configuration file are used.  If the configuration file specifies no sources, uses the default NuGet feed.
list        Displays a list of packages from a given source. If no sources are specified, all sources defined in %AppData%\NuGet\NuGet.config are used. If NuGet.config specifies no sources, uses the default NuGet feed.
pack        Creates a NuGet package based on the specified nuspec or project file.
push        Pushes a package to the server and optionally publishes it.
NuGet
  's default configuration is obtained by loading %AppData%\NuGet\NuGet.config, then loading any nuget.config or .nuget\nuget.config starting from root of drive and ending in current directory.
setApiKey   Saves an API key for a given server URL. When no URL is provided API key is saved for the NuGet gallery.
sources     Provides the ability to manage list of sources located in  %AppData%\NuGet\NuGet.config
spec        Generates a nuspec for a new package. If this command is run in the same folder as a project file (.csproj, .vbproj, .fsproj), it will create a tokenized nuspec file.
update      Update packages to latest available versions. This command also updates NuGet.exe itself.

For more information, visit http://docs.nuget.org/docs/reference/command-line-reference

How to download NuGet.CommandLine tool

Open up NuGet Package Explorer, and then click Open a package from online feed

image

Search NuGet.Command

image

Expend tools in the right window, right click on NuGet.exe, save it to any local directory

image

The file name, default is NuGet.exe

image

Using Command Prompt and locate to NuGet.exe folder (C:\TEMP\NuGet\ as the example here)

List all available commands and their description by typing NuGet Help

image

2013年5月23日 星期四

Host Our Own NuGet Feed by installing NuGet.Server

 

image

Install-Package NuGet.Server

image

Open Web.config file, make sure to delete first <compilation …> node due to i don’t have .NET framework 4.5 installed in my local

image

Ctrl-F5 to run the application

image

Click here to the link http://localhost:xxx/nuget/Packages, so far no package inside

image

Let’s add a new source feed to our local server

image

No package could be found so far

image

****************************************************************************************************

 

Let’s do copy and paste a package into our project->packages folder

Copy from temp folder

image

Paste to Visual Studio project –> Packages folder

image

After that, refresh the page again, we will see the package shows

image

It’s more clear showing in IE browser

image

We can also find it in Manage NuGet Packages window

image

Or using Package Manager Console, Get-Package –ListAvailable (don’t forget to swith to righ source)

image

LINQPad is also supported

image

Install self-created NuGet package with dependency

In the previous blog, Create a new NuGet package, we successfully create a NuGetExample.1.0.0.nupkg

image

Now, let’s using it in our Visual Studio project.

Create an empty MVC4 project, so far there is no Scripts folder

image

We can install jQuery but version 1.7 first into our project by execute command in Package Manager Console

Install-Package jQuery –Version 1.7

Now, Scripts folder and 3 jQuery .js files are added

image

Click to open Package Manager Settings

image

Add a new local source which we created in previous blog

image

Open Manager NuGet Packages window, switch to “Local 2” source, we are now able to install our own package, NuGetExample with jQuery 2.0 dependency

image

Installing…in progress

image

After that, we can see both our script file, MyNuGetScript.js and jQuery 2.0 are added in our project

image

*********************************************************************************************************

By the way, if we are trying to Uninstall-Package jQuery, we will encounter an error saying that due to NuGetExample has dependency with jQuery

image

Create a new NuGet package

Download NuGet Package Explorer and install it

image

After installation, double click to open it and click Create a new package

image

In the CONTENT menu, select Add –> Content Folder

image

Right click on content –> Add New Folder, Scripts

image

Right click on Scripts folder –> Add Existing File…

image

Select the existing file that we created in advance, MyNuGetScript.js, for example

image

Right click on MyNuGetScript.js –> View Content

image

 

Now we would like to add Dependency of this package, jQuery, for example.

In EDIT menu –> Edit Metadata

image

Scoll down to bottom, click on Edit dependencies button

image

Add a new group

image

Select dependency from NuGet feed

image

Search jQuery, and double click to select it

image

Click + to add, then click OK

image

Click Save

image

Now we can see the jQuery list in Dependencies

image

Save the package

image

By default, the file name will be [Id][Version].nupkg

image

2013年5月22日 星期三

NuGet Documents of Package Manager Console

PowerShell command documents can be found in the link http://docs.nuget.org

Scoll down a bit to click the link, Package Manager Console PowerShell Reference

image

We can see the PowerShell commands in the right hand side of screen, Doc Outline.

Each command including 3 parts.

image

In Visual Studio, we can also type Get-Help NuGet to see the document

image

Get-Help Get-Package

image

Get-Help get-package –example

image