Thursday, June 9, 2016

NuGet Commands Asp.net



Get List of Installed Packages :-
Get-Package -ListAvailable

Get-Package -ListAvailable -Filter elmah

Install- Package :-
Install-Package elmah

UnInstall-Package :-
Uninstall-Package elmah

Updating Package :-
Get-Package -updates

Updating Nuget :-
nuget.exe update -self


INSTALLATION ERROR IN NUGET:-
Install-Package : 'AutoMapper' already has a dependency defined for 'Microsoft.CSharp'.
At line:1 char:16
+ Install-Package <<<<  AutoMapper -Verbose
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

Solution:-

  • Find the Cache folder of VS 2012's Nuget Package Manager (with Tools - Options - Nuget Package Manager)
  • Open AutoMapper.5.x.x.nupkg with your favorite Zip Tool
  • Modify the file AutoMapper.nuspec - I simply deleted all dependencies except .NETFramework4.5
  • Add the cache folder as a Nuget source (also in Tools - Options - Nuget Package Manager)
  • Install Automapper either with the console or the GUI but make sure to choose first the newly added cache folder as package source.

Reference URL:- https://docs.nuget.org/consume/package-manager-console