All notes
Nug

# Command line


Get-Help Get-Package

:: Without any flags to see a list of installed packages
Get-Package

:: See a list of all packages
:: NuGet 3.0 Beta or higher, Get-Package also takes a -PageSize switch.
Get-Package -ListAvailable
:: Better to add a filter:
Get-Package -Filter Logging -ListAvailable
:: NuGet client 3.0 Beta or higher, these Get-Package commands can be replaced by
Find-Package Logging

Uninstall-Package elmah

:: Update package
Update-Package jQuery


## Install

NuGet retrieves the package from the specified package source and installs it in the project that is selected in the Default project drop-down list (unless you specify a different project in the command).

The packages folder contains a subfolder for each installed package. This subfolder contains the files installed by the package. It also contains the package file itself (the .nupkg file, which is a .zip file that contains all of the files included in the package).

### Install all the packages in the packages.config

SO.


Update-Package -reinstall -Project YourProjectName


## Uninstall

If other packages were installed because they were dependencies of the package that you removed, and if no other packages remain that are dependent on the dependency packages, the dependency packages are also removed.

## NuGet Powershell Profile

NuGet supports a NuGet specific profile typically located at: %UserProfile%\Documents\WindowsPowerShell\NuGet_profile.ps1.

The easiest way to find the profile file is to type $profile within the NuGet Package Manager Console. $profile
:: C:\Users\philha\Documents\WindowsPowerShell\NuGet_profile.ps1


This file doesn't necessarily exist by default. You can run the following set of commands to create it.


mkdir -force (split-path $profile) notepad$profile


Within the profile file, you can change PowerShell settings or add new commands you might find useful. Here is a simple example of adding a command that allows you to set the font.


function Set-FontSize {
param(
[ValidateRange(6, 128)]
[Parameter(position=0, mandatory=$true)] [int]$Size
)
$dte.Properties("FontsAndColors", "TextEditor").Item("FontSize").Value =$Size
}


Save the profile file and then restart Visual Studio. The next time you open the Package Manager Console, you will be able to make use of the Set-Font command: Set-FontSize 24.

# FAQ

## Start package manger Console

From the Tools menu, select "Library Package Manager" and then click Package Manager Console.

## Error “Id is required”

Symtoms:

Install-Package Hangfire

Id is required.
Version is required.
Authors is required.
Description is required.


Solution: Go to Tools - Extension Manager - Updates - Update Nuget. In my case I had to update from version 1.0.11220.104 to 2.5.40416.9020.

## Installed package not shown in references

Got it to work in VS2010, .NET 4.0 with a MVC4 using these nuget commands:


Install-Package Microsoft.Owin.Host.SystemWeb -Version 2.1.0
Install-Package HangFire -Version 0.9.1


0.9.1 is the last version that a supported 4.0. Also, you have to run with IIS & not the VS Development Server.