1658822440
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.
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.
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.
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:
The NuGet Package Manager in Visual Studio on Windows allows you to easily install, uninstall, and update NuGet packages in projects and solutions.
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.
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.
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.
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:
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.
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.
You can clear NuGet by following one of these ways:
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.
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.
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
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
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
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
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
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
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
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.
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
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
The uninstall-package command removes a NuGet package from the project.
uninstall-package <Package Name>
Example
uninstall-package Syncfusion.Data.WPF
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
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.
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:
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
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
The remove package command removes a package reference from a project file:
dotnet remove package <Package Name>
Example
dotnet remove package Syncfusion.SfGrid.WPF
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
I hope this blog enriched your knowledge about managing NuGet packages in .NET projects.
#microsoft #nuget
1638460800
This video covers how to build and push docker images to Github Package registry.
1635585660
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#.
1634019706
Updating NuGet packages from command-line - deep dive https://blog.elmah.io/updating-nuget-packages-from-command-line-deep-dive/ #dotnet #dotnetcore #nuget
1631178000
In this video you will learn about: How to create, upload & install nuget package in asp.net core.
1628935500
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
1625487300
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
1625118900
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.
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
1623742216
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
1623170880
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.
…
#database #nosql #ravendb #nuget #sentiment analysis #powering up ravendb indexes with nuget packages
1618823880
1618492620
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
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
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
1611868800
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
1605079800
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
1599669600
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.
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:
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:
'master'
#tutorial #devops #c# #github #csharp #nuget #continious integration #github actions #nuget packages