Installing Packages
Add NuGet packages to your .NET projects.
Installation Methods
From the NuGet Manager
- Open the NuGet Package Manager
- Switch to the Browse tab
- Search for the package you want
- Select the package from results
- Choose the target version
- Select which projects to install to
- Click Install
From Solution Explorer
- Expand a project's Dependencies node
- Right-click on the Packages node
- Select "Add Package"
- Search and select the package
- Click Install
From Command Palette
- Press
Ctrl+Shift+P
- Type "NuGet: Add Package"
- Select the command
- Choose the project
- Search for the package
- Select version and install
Selecting Target Projects
When installing from the solution level:
- Check the projects that should receive the package
- All selected projects will get the same version
- Click Install to add to all selected projects
Project Compatibility
The extension will:
- Show only compatible projects for the package
- Warn if target framework doesn't match
- Prevent installation to incompatible projects
Installation Process
When you click Install:
- The package is downloaded from the source
- The project file (.csproj) is updated
- Dependencies are resolved and downloaded
- The package appears in the Dependencies node
- References are added to the project
Installing Specific Versions
To install a specific version:
- Select the package
- Click the version dropdown
- Choose the desired version
- Click Install
When to Use Specific Versions
- Latest stable: Default choice for most scenarios
- Specific version: When you need compatibility with other packages
- Pre-release: To test new features (not recommended for production)
Installing with Dependencies
Packages often require other packages (dependencies):
Automatic Dependency Resolution
The NuGet manager automatically:
- Identifies required dependencies
- Downloads all dependencies
- Installs them in the correct order
- Resolves version conflicts
Viewing Dependencies
Before installing, expand the Dependencies section to see:
- Required packages
- Minimum versions
- Framework requirements
Post-Installation
After installation:
- The package is available for use in code
- Add
using
statements for the package namespaces - IntelliSense will show types from the package
- Build the project to restore and verify
Troubleshooting
Installation Failed
If installation fails:
- Check the Output panel for error details
- Verify internet connectivity
- Ensure sufficient disk space
- Check for package source issues
- Verify project file permissions
Version Conflicts
If you encounter version conflicts:
- Review the error message for conflicting packages
- Update or downgrade conflicting packages
- Use package consolidation features
- Consider using binding redirects (for .NET Framework)
Package Not Found During Restore
If the package isn't restored after installation:
- Try manual package restore
- Check nuget.config for source configuration
- Verify package exists in the configured sources
- Clear NuGet cache and retry