Callum Slater

Callum Slater

1658822440

How to Increase Your Productivity with Manage NuGet Packages

In this hands-on tips-and-tricks session, you’ll learn how to increase your productivity and discover a few new things about your favorite package manager directly from the NuGet team. Bring your questions as there will be plenty of time for Q&A.


How to Use NuGet Packages: The Ultimate Guide

NuGet is a package manager that delivers compiled source code (DLLs) and other files (scripts and images) related to code. A NuGet package takes the form of a zip file with the extension .nupkg. This makes adding, updating, and removing libraries easy in Visual Studio applications. Using NuGet to install and update packages reduces the manual work of configuring third-party libraries in an application by installing a setup or extracting a zip file and adding the required assemblies to references and files.

Configure the NuGet feed

 What is the feed link?

The feed link is a URL that is the location of the NuGet package published in the localhost or local directory. You can get a package only through a feed link from the host.

How to configure the feed

By default, Visual Studio is configured with the public NuGet feed link.

To configure the private feed link or a local path in Visual Studio, follow these steps:

  1. In Visual Studio, go to Tools > Options and then select Package Sources under the NuGet Package Manager.
  2. Choose the Add icon (+), edit the Name, and then provide the feed link or local path in the Source Click Update after updating the feed link.Updating the Feed Link.Updating the Feed Link.

NuGet Package Manager

The NuGet Package Manager in Visual Studio on Windows allows you to easily install, uninstall, and update NuGet packages in projects and solutions.

Install a third-party NuGet package

  1. In Solution Explorer, right-click either Solution, a project, or the References in a project, and then select Manage NuGet Packages.Managing NuGet Packages in a Project with Nuget Package manager.Managing NuGet Packages in a Project with Nuget Package manager.
  2. The Browse tab displays packages by popularity from the currently selected source. Search for a specific package using the search box at the top-left corner. Select a package from the list to display its information, which also makes the Install button available along with a drop-down for selecting a package version.Selecting a Package and Its Version.Selecting a Package and Its Version.
  3. Select the desired version from the drop-down, and then click Install. Now, Visual Studio installs the package and its dependencies into the project. You may be asked to accept license terms and shown the list of NuGet packages, including dependencies, in a Preview Changes When installation is completed, the added packages appear in the Installed tab. Packages are also listed in the References either as assemblies or package references, indicating that you can refer to them in the project using statements.

Install beta NuGet packages

By default, prerelease-versioned packages are not available when searching NuGet. Only stable versions are available. If you want to include prerelease versions in your search, select the Include prerelease option next to the search box.

Searching Including Prerelease Versions.

Searching Including Prerelease Versions.

Install NuGet packages without dependencies

By default, when installing NuGet packages, corresponding package dependencies will also be installed in your project. To avoid the installation of dependent packages, choose the Ignore Dependencies option in the Dependency behavior drop-down in NuGet Package Manager.

Installing NuGet Packages Without Dependencies.

Installing NuGet Packages Without Dependencies.

Uninstall a NuGet package

  1. In Solution Explorer, right-click either the Solution, the desired project, or the References in the project, and then select Manage NuGet Packages.
  2. Select the Installed
  3. Select the package to uninstall (use search to filter the list if necessary), and then select Uninstall.Uninstalling a NuGet Package.Uninstalling a NuGet Package.

Remove dependencies when uninstalling NuGet packages

To uninstall the dependency packages of a selected NuGet package, choose the Remove Dependencies option from the NuGet Package Manager.

Removing Associated Dependencies when Uninstalling a NuGet Package.

Removing Associated Dependencies when Uninstalling a NuGet Package.

Update NuGet packages

  1. In Solution Explorer, right-click either the Solution, the desired project, or the References of the project, and then select Manage NuGet Packages.
  2. Select the Updates tab to see the packages that have updates available from the selected package sources. Select the Include prerelease check box if you want to include prerelease package versions.
  3. You have two options here: If you want to update all the updates that are available, select the Select all packages check box, and then click the Update If you want to update a specific package, select the package and desired version from the drop-down on the right, and then click the Update button.Updating All Packages.Updating All Packages.

Restore NuGet packages

Package Restore installs the direct dependencies of a project as needed and then installs any dependencies of these packages throughout the entire dependency graph. When the project is opened or compiled, all the added NuGet packages will be restored. Follow these steps to use this feature:

  • Navigate to Tools > Options > NuGet Package Manager > General, and then select the Allow NuGet to download missing packages check box under Package Restore.
Enabling Restore NuGet Packages.
  • In Solution Explorer, right-click the solution, and then select Restore NuGet Packages.Selecting Restore NuGet Packages.Selecting Restore NuGet Packages.

Clear NuGet packages

Clear NuGet packages is an action that removes already installed NuGet caches from the cache location. Usually the NuGet packages are installed from the cache location if one exists, otherwise it will be downloaded from the corresponding feed in the cache location.

Why do we need to clear NuGet?

If you encounter package installation problems or if you want to ensure that you’re installing packages that have been configured locally (your own packages), clear the NuGet cache in the cache location to resolve the issues.

How to clear NuGet

You can clear NuGet by following one of these ways:

  1. Manually remove the NuGet cache from this location: (%userprofile%\.nuget\packages).
  2. Clear the cache automatically through Visual Studio by choosing the following option: Go to

Tools > NuGet Package Manager > Package Manager Settings > General or Tools > Options > NuGet Package Manager > General, and then click Clear All NuGet Cache(s).Clearing (Removing) All NuGet Caches Automatically.Clearing (Removing) All NuGet Caches Automatically.

Package Manager Console

The NuGet Package Manager Console uses NuGet PowerShell commands to find, install, uninstall, restore, and update NuGet packages. The console is built into Visual Studio on Windows.

  1. Open your project or solution in Visual Studio, and then open the Package Manager Console in Visual Studio by navigating to Tools > NuGet Package Manager > Package Manager Console.
  2. By default, console commands operate against a specific package source and project as set in the control at the top of the window. To manage package sources, select the gear icon. This is a shortcut to Tools > Options > NuGet Package Manager > Package Sources.Setting up the Package Manager Console.Setting up the Package Manager Console.

Install a NuGet package

Install a package using the console by entering the following command:

Install-Package <Package Name> -Version <version>

Example:

PM> Install-Package Syncfusion.SfChart.WPF -Version 17.3.0.14

Install a beta NuGet package

If you want to install a beta (prerelease) NuGet package using the console, include -IncludePrerelease in the command:

Install-Package <Package Name> -Version <version> IncludePrerelease

Example:

PM> Install-Package Syncfusion.SfChart.WPF -Version 17.2.0.28-beta -IncludePrerelease

Install a NuGet package without dependencies

If you want to install a package without dependencies using the console, use -IgnoreDependencies in the command:

Install-Package <Package Name> -Version <version> IgnoreDependencies

Example:

PM> Install-Package Syncfusion.SfChart.WPF -Version 17.2.0.28-beta -IgnoreDependencies

Uninstall a NuGet package

To uninstall a package from the project through the console, use the following command:

Uninstall-Package <Package Name>

Example:

PM> Uninstall-Package Syncfusion.SfChart.WPF

Remove dependencies when uninstalling a NuGet package

To remove the dependencies of a selected package when uninstalling it through the console, use -RemoveDependencies in the uninstall command.

Uninstall-Package <Package Name> -Version <Version> -RemoveDependencies

Example:

PM> Uninstall-Package Syncfusion.SfChart.WPF -RemoveDependencies

Update NuGet packages

The Update-Package command is used to upgrade or downgrade an existing package in your project.

Update-Package [Package Name] <string> [-Version] <string> [-IgnoreDependencies]

Example:

PM> Update-Package Syncfusion.SfChart.WPF -Version 17.2.0.40 -ignoreDependencies

Update beta NuGet packages

To update prerelease (beta) packages, use the following command:

Update-Package [Package Name] <string> [-Version] <string> [-IgnoreDependencies] [-IncludePrerelease]

Example:

PM> Update-Package Syncfusion.SfChart.WPF -Version 17.2.0.40 -ignoreDependencies -IncludePrerelease

NuGet CLI

The NuGet CLI tool allows you to easily update and restore NuGet packages in projects and solutions. To execute NuGet CLI commands, you must have the nuget.exe file. You can download it from nuget.org.

The NuGet CLI requires a packages.config file for package references. This should be placed in the project location.

Open the command prompt, and then navigate to the directory that contains the project file to execute the NuGet CLI commands.

Install a package

The install command downloads and installs the package into the project from specified package sources. When installing the package, it is placed in the project’s root directory by default.

Use the following command to install a NuGet package in the packages folder:

nuget install <Package Name> -OutputDirectory <OutputPath>

Example

nuget install Syncfusion.Data.WPF -OutputDirectory D:\Sample

Install a package with a specific version

NuGet installs the latest version of a package when using the install command unless you specify the package version. Specify the version in the install command to install a specific version of the package.

nuget install <Package Name> -Version <Version>

Example

nuget install Syncfusion.Tools.windows -Version 17.2.0.40

Uninstall a NuGet package

The uninstall-package command removes a NuGet package from the project.

uninstall-package <Package Name>

Example

uninstall-package Syncfusion.Data.WPF

Uninstall dependent NuGet packages

When uninstalling a NuGet package that depends on other packages, use the -Force command.

uninstall-package <Package Name> -Force

Example

uninstall-package Syncfusion.Data.WPF -Force

Nuget Restore

To restore the solution with the help of the NuGet CLI, use the restore command. It will restore all the packages available in the package.config.

nuget restore <SolutionFile>

Example:

nuget restore D:\NuGet\NuGetDemo.sln

Restore only adds packages to the disk; it does not change a project’s dependencies. To restore a project’s dependencies, modify packages.config and then use the restore command.

dotnet CLI

The dotnet CLI allows you to easily install, uninstall, and update NuGet packages in projects and solutions. It runs on Windows, Mac OS X, and Linux.

Open a command prompt, and then navigate to the directory that contains the project file. Use the following dotnet CLI commands to perform the respective operations:

Install a package

Use the add package command to add a package into the project references:

dotnet add package <Package Name>

Example

dotnet add package Syncfusion.SfGrid.WPF

Install a specific version of a package

If a version is not specified, NuGet installs the latest version of the package. You can also use the dotnet add package command to install a specific version of a NuGet package:

dotnet add package <Package Name> <Version>

Example

dotnet add package Syncfusion.SfGrid.WPF 17.2.0.40

Remove a package

The remove package command removes a package reference from a project file:

dotnet remove package <Package Name>

Example

dotnet remove package Syncfusion.SfGrid.WPF

Restore a package

To restore a package, use the dotnet restore command. It restores the project references from the current directory:

dotnet restore [Project|Solution]

Example

dotnet restore D:\NuGetDemo\NuGetDemo.csproj

Conclusion

I hope this blog enriched your knowledge about managing NuGet packages in .NET projects.

#microsoft #nuget 

How to Increase Your Productivity with Manage NuGet Packages
Mireille  Von

Mireille Von

1638460800

How to Create and Push A Docker Image To The Github Package Registry.

This video covers how to build and push docker images to Github Package registry.

#github #docker #nuget 

How to Create and Push A Docker Image To The Github Package Registry.

How to Create and Publish a Nuget Package?

Create and Publish a Nuget Package (.NET Framework - Custom Controls). In this tutorial you will learn how to Create and publish a Nuget package of the Custom Controls created in the previous videos using .NET Framework, Windows Forms and C#.

#dotnet #csharp #visual-studio #nuget 

How to Create and Publish a Nuget Package?

Thomas Ardal

1634019706

Updating NuGet packages from command-line - deep dive
Andre  Fisher

Andre Fisher

1631178000

instructions for Creating, Uploading and Installing .NET Core NuGet

In this video you will learn about: How to create, upload & install nuget package in asp.net core.

#nuget   #dotnet 
 

instructions for Creating, Uploading and Installing .NET Core NuGet
Ruthe  Sawayn

Ruthe Sawayn

1628935500

Azure DevOps: How to Create NuGet Packages ?

In this Video I’ll show how we can create NuGet Packages in the Azure DevOps.

Sections in this Video
##############
0:00 - Introduction of NuGet
0:18 - Create Artifact
1:34 - Creating NuGet Package in Continuous Integration
3:37 - Add the created dll (NuGet ) into Project
5:33 - Create Versioning of NuGet
6:40 - Best Place to Create NuGet Package during CI/CD

This is a part of my complete Free course available on Udemy. You can find the course here - https://www.udemy.com/course/azure-de

You can also check my other courses on Udemy -
Azure DevOps with Git -
https://www.udemy.com/course/azure-de

Azure DevOps-Code Versioning with TFVC-
https://www.udemy.com/course/azure-de

To know more about NuGet - https://docs.microsoft.com/en-us/azure/devops/artifacts/get-started-nuget?view=azure-devops&tabs=windows

Don’t forget to Subscribe the Channel.

#devops #azure #nuget

Azure DevOps: How to Create NuGet Packages ?
Annie  Emard

Annie Emard

1625487300

NuGet PackageReference Versions SOLUTION Wide

Having NuGet Packages across multiple projects can be a challenge. Each PackageRefence across csproj files must specify the same version of the NuGet Package.

Two ways to simplify your NuGet PackageReferences in your C# Projects. Use Directory.Build.targets or Directory.Packages.props to keep a common place for specifying the version of a NuGet Package.

Stuart Lang Blog Post: https://stu.dev/managing-package-versions-centrally/

🔔 Subscribe: https://www.youtube.com/channel/UC3RKA4vunFAfrfxiJhPEplw?sub_confirmation=1

💥 Join this channel to get access to source code, demos, and slides!
https://www.youtube.com/channel/UC3RKA4vunFAfrfxiJhPEplw/join

📝 Blog: https://codeopinion.com

📚 Book Recommendations

Domain-Driven Design
https://amzn.to/2QwG8sb

Patterns of Enterprise Application Architecture
https://amzn.to/3d8kMJj

Refactoring: Improving the Design of Existing Code
https://amzn.to/2NVdP5Q

Monolith to Microservices: Evolutionary Patterns to Transform Your Monolith
https://amzn.to/3srUuZ6

RESTful Web Clients: Enabling Reuse Through Hypermedia
https://amzn.to/3d8Q96B

CodeOpinon: https://codeopinion.com
Twitter: https://twitter.com/codeopinion

#nuget #packagereference #solution wide

NuGet PackageReference Versions SOLUTION Wide

Should You Always Create a Nuget Package? Asking for a Friend...

I have a couple of public projects (this blog, and the code camp website) that both use Azure Blob storage to store images for the sites. I’ve felt guilty that I’ve copy/pasted the code between them for a while. I decided to fix it.

While the code was pretty simple, I did need to change it a bit to generalize it. But then I wondered, would it be useful for anyone else? I decided to just make it a Nuget package. But should I have? We’ll get to that in a minute, let’s talk about how I generalized it first.

Generalizing the Code

Originally, the code was a simple class that did all the work in a single method. But to generalize it I needed to move code that was specific to my implementations out. First to go was the IConfiguration usage. In the old code, I was simply importing configuration (as AppSettings):

public ImageStorageService(IOptions<AppSettings> settings, 
  ILogger<ImageStorageService> logger)	
{	
  _settings = settings;	
  _logger = logger;	
}

Then using the app settings to create the credential into Azure Blob Storage:

var creds = new StorageSharedKeyCredential(_settings.Value.BlobStorage.Account,   
                                           _settings.Value.BlobStorage.Key);	
var client = new BlobServiceClient(new Uri(_settings.Value.BlobStorage.StorageUrl), creds);

I didn’t like this. To generalize this, I needed to derive the credentials to store the extra piece of information (the StorageUrl):

public class AzureImageStorageCredentials : StorageSharedKeyCredential
{
  public AzureImageStorageCredentials(string accountName, string accountKey, string url)
    :base(accountName, accountKey)
  {
    AccountUrl = url;
  }

  public string AccountUrl { get; private set; }

}

This way we could just inject it into the service as needed:

public AzureImageStorageService(ILogger<AzureImageStorageService> logger, 
  AzureImageStorageServiceClient client)
{
  _logger = logger;
  _client = client;
}

FInally, to clean up the code, I hid the service registration in an extension method:

public static IServiceCollection AddAzureImageStorageService(this IServiceCollection coll, 
  [NotNull] string azureAccountName,
  [NotNull] string azureAccountKey,
  [NotNull] string azureStorageUrl)
{

  coll.AddScoped(coll => new AzureImageStorageCredentials(azureAccountName, 
                                                          azureAccountKey, 
                                                          azureStorageUrl));
  coll.AddScoped<AzureImageStorageServiceClient>();
  coll.AddTransient<IAzureImageStorageService, AzureImageStorageService>();

  return coll;
}

This seemed all good, but now that i’ve generalized it with the derived credential, the dummy credentials that I used during development simply broke. I needed to verify that the key was Base64 encoded:

public static IServiceCollection AddAzureImageStorageService(this IServiceCollection coll, 
  [NotNull] string azureAccountName,
  [NotNull] string azureAccountKey,
  [NotNull] string azureStorageUrl)
{
  // Test for valid Base64 Key
  Span<byte> buffer = new Span<byte>(new byte[azureAccountKey.Length]);
  if (!Convert.TryFromBase64String(azureAccountKey, buffer, out int bytesParsed))
  {
    throw new InvalidOperationException("Azure Account Key must be a Base64 Encoded String. If running in development, mock the IImageStorageService for development instead.");
  }

  coll.AddScoped(coll => new AzureImageStorageCredentials(azureAccountName, azureAccountKey, azureStorageUrl));
  coll.AddScoped<AzureImageStorageServiceClient>();
  coll.AddTransient<IAzureImageStorageService, AzureImageStorageService>();

  return coll;
}

That’s all and well…but…

#c# #nuget #packages #dependency injection

Should You Always Create a Nuget Package? Asking for a Friend...

Arun A

1623742216

Introducing Individual NuGet Packages for Syncfusion Blazor UI Components

We at Syncfusion are happy to inform you that new individual NuGet packages for our Syncfusion Blazor UI components are now available from the 2020 Volume 4 release (v18.4.0.30).

The Syncfusion.Blazor NuGet source has been segregated based on the component and namespace. Each NuGet package uses the same namespace as in the NuGet Syncfusion.Blazor source. So, the new migration will not break your applications.
https://www.syncfusion.com/blogs/post/introducing-individual-nuget-packages-for-syncfusion-blazor-ui-components.aspx

#blazor #components #web-development #nuget

Introducing Individual NuGet Packages for Syncfusion Blazor UI Components
Ruth  Nabimanya

Ruth Nabimanya

1623170880

Powering Up RavenDB Indexes With NuGet Packages - DZone Database

How to Pull in Third-Party Packages to Index EXIF Image Data or Perform ML.NET Sentiment Analysis on Document Data.

In RavenDB 5, you can use third-party NuGet packages and load binary data (or “attachments”) within your indexes without any additional code deployment necessary.

In this article, I’ll showcase how to use these two features together to index EXIF metadata on images and run ML.NET sentiment analysis offline on product reviews.

What Makes RavenDB Indexes So Powerful?

Indexing Image EXIF Data Using Attachments

User Review Sentiment Analysis With ML.NET

#database #nosql #ravendb #nuget #sentiment analysis #powering up ravendb indexes with nuget packages

Powering Up RavenDB Indexes With NuGet Packages - DZone Database
Layne  Fadel

Layne Fadel

1618492620

How to Create A Template in .NET for A C# Application and What NuGet Is For

Plan

1. What is an application template in .NET

2. What NuGet is for

3. Create NuGet application template

4. How to publish the NuGet template

What for you need this

1. To understand this tool and broaden your skills horizons

2. To take out useful and often necessary functionality into templates

3. To understand how to use NuGet from the command line

What is an application template in .NET?

When you installing Visual Studio via Visual Studio Installer or modifying existing installation you are selecting workloads and components which contains predefined templates.

#microsoft #nuget #programming #development #c-sharp-programming

How to Create A Template in .NET for A C# Application and What NuGet Is For
dot NET

dot NET

1611868800

DevOps for ASP.NET Developers: Hosting NuGet Packages

NuGet defines how packages for .NET are created, hosted, and consumed, and provides the tools for each of those roles. Using NuGet feeds, you can make your packages publicly available or limit them to an audience, such as your internal team.

In this episode, Abel shows Jeremy some different options for publishing and hosting your own NuGet packages.

[00:38] - Versioning dependencies with NuGet
[02:47] - Creating NuGet packages basics
[03:54] - Setting up a package feed in Azure DevOps Artifacts
[05:05] - Building packages in Azure DevOps Pipelines
[08:47] - Publishing and hosting NuGet feeds to GitHub

NuGet Package creation workflow
https://docs.microsoft.com/nuget/create-packages/overview-and-workflow?WT.mc_id=dotnet-00000-cephilli

Publishing NuGet packages
https://docs.microsoft.com/nuget/nuget-org/publish-a-package?WT.mc_id=dotnet-00000-cephilli

GitHub Packages
https://github.com/features/packages

#aspdotnet #dotnet #web-development #devops #nuget

DevOps for ASP.NET Developers: Hosting NuGet Packages

Aman Agrawal

1605079800

Using NuGet to publish .NET packages

NuGet is a free and open-source package manager for the .NET ecosystem. We can create and install packages using NuGet client tools. All of the .NET packages are hosted for publishing and consumption on a central package repository known as NuGet Gallery.

Check out this blog to learn more about how you can use NuGet to publish .NET packages

https://www.loginradius.com/engineering/blog/using-nuget-to-publish-net-packages/

#nuget #.net #developer #programming #engineering

Using NuGet to publish .NET packages
Dock  Koelpin

Dock Koelpin

1599669600

Publish NuGet Packages Using GitHub Actions

Unbelievable! One of the oldest NetLicensing Client libraries for C# (with the first GitHub push made on Oct 2, 2013) was not available in one of the essential package managers for .NET

Better late than never — so we decided to change this status quo, and today want to share with you our this walkthrough on how we published NetLicensing C## Client library to NuGet repository using GitHub Actions.

Background Info — GitHub Flow

Before moving forward, just a note about GitHub Flow workflow adopted for Labs64 projects hosted at GitHub.

“Pull Request” or “PR” is a very useful feature of the GitHub version control system and allowing efficient feature and bugfix development with the GitHub Flow.

The below diagram showing GitHub Flow adopted for Labs64 projects:

GitHub Flow

Any new feature or defect fix implementation is being done only in a dedicated feature branch. When branch implementation is ready to be integrated into the master branch, a Pull Request gets created. Using this PR, team members, working on a particular feature/enhancement/bug fix, can get feedback from other team members along the way.

This feedback is being used to make further changes and commits to the branch before finally merging the changes back up to the 'master' branch.

For the above GitHub Flow following workflows will be defined:

  • CI — build and test push commits at Pull Request branches and master
  • Release — package and publish C## library after successful CI run on 'master'

#tutorial #devops #c# #github #csharp #nuget #continious integration #github actions #nuget packages

Publish NuGet Packages Using GitHub Actions