SlideShare a Scribd company logo
1 of 16
Download to read offline
Introduction To Package Manager
Yashobanta Bai
yashobanta.bai@gmail.com
Agenda: Creating, Publishing and Consuming NuGet Package.
 Introduction to Package Manager.
 Packaging Steps.
 Creating a NuGet Core package using Visual Studio IDE.
 Creating a NuGet Core package using .NET CLI Tool.
 Creating a NuGet .NET Framework package using NuGet CLI Tool.
 Config file transformations.
 Including package dependencies using .nuspec file..
 Publishing a Package into NuGet public repository using NuGet.org web interface.
 Publish package into NuGet public repository using Dot net core CLI.
 Publishing a Package into a Local repository.
 How to consume packages available in the Local repository:
 Publishing a Package into MyGet repository.
 How to consume packages available in the MyGet repository.
 Publishing a Package into Azure DevOps repository.
 How to create and publish a NPM package?
What is a package manager?
Package Manager is a tool used to simplify the process of installing, configuring, upgrading and removing of
software packages.
Why we need a Package Manager?
When we want to consume any library from our code we generally follow certain steps such as,
 Search for the required library.
 Install the library.
 Add the reference to the DLL.
 Configure the library if needed.
After some day if we need to update our library because we found some critical bug or security hole then we
need to follow some steps to remove it from the current project and again follow above repeated steps to refer
the new library. As day by day the amount of libraries available for any given language or technology are
increases and in a given software project we may used hundreds of libraries, so it is very difficult to manually
manage the library packages . So we required a proper tool to manage all our packages.
Popular Package Manager Tool:
NuGet: Package manager for the Microsoft development platform.
NPM: package manager for Node.js and JavaScript
Reference : https://www.nuget.org/ , https://www.npmjs.com/
What is a NuGet Package?
The NuGet package is just a ZIP file with a extension of .nupkg and is contains compiled code ,other
supported file require for the package, and a descriptive manifest that includes information like, the package's
version number, Package Id,author , company etc.
Reference: https://docs.microsoft.com/en-us/nuget/reference/nuspec
Packaging Steps:
There are some basic steps we need to follow for packaging and this process is common for mostly all type
packages like NuGet, npm etc.
Step 1: Write required source code
 Write the code to implement the Business requirements and test the library thoroughly to make sure that
its working as expected.
Introduction To Package Manager
Yashobanta Bai
yashobanta.bai@gmail.com
 You are free to create a .NET Framework libraries , .NET Core libraries etc.
Step 2: Create a package.
 To create a package you can use any NuGet client tool such as Visual Studio IDE, dotnet.exe or nuget.exe
 dotnet.exe tool is for .NET Core libraries.
Step 3: Publish the package into a package repository.
As per your business requirements you can select any type of repository.
 Public Repository: If you want that your package should available to everyone then you should chose a
public repository like Nuget.org.
 Private Repository: There might be some scenarios where you might want to release packages to only a
limited audience or you want some restriction over the package uses then you should go for a private
repository. It may be a local private repository or remote private repository.
Local Private Repository: Local NuGet package feeds are simply a collections of folder on your local
network.
Remote Private Repository: There are some NuGet hosting providers who provides services for private
repository and popular examples are MyGet and Azure DevOps.
Step 4: Consume the package.
 Consumer application can browse the packages using a package manager tool and consume it where ever
required.
Creating a NuGet Core package using Visual Studio IDE
 Open Visual Studio, go to File - New and select a .Net Core Class Library project.
 Write some sample code.
using System;
namespace SampleLibrary
{
public class Utility
{
public string ToUpper(string input)
{
return input.ToUpper();
}
}
}
Introduction To Package Manager
Yashobanta Bai
yashobanta.bai@gmail.com
 Right-click on the project, choose Properties and go to the package tab.
 Check the check box at the top and then fill in the package information as required.
Package ID This is a unique identifier used to identify your package uniquely..
Version This is a version of the package like 1.0.0.
Author This field holds authors of the package.
owners Generally Author and owner both contains same value i.e creator of the package.
iconUrl We can specify an icon for the package. The size of the image should be a 32x32 pixel png
image with transparent background.
copyright Specify copyright details for the package.
tags Tags are nothing but keywords and can be used to search the package.
releaseNotes This going to hold the release notes of the project.
description As the name suggests, this is a long description of the package.
 Build the class library in the release mode.
Congratulations!! You are ready with your first NuGet package. Now you can publish into any type of
NuGet repository.
Creating a NuGet Core package using .NET CLI Tool
 Create a .net core library using CLI
F:> mkdir DemoApp
F:> dotnet new classlib -n SampleUtility -o DemoApp
-n stands for name of the class library and -o stands for output directory
 Open the project file in any supported editor such as Visual Studio Code and write your sample code.
using System;
namespace SampleLibrary
{
public class Utility
{
public string ToUpper(string input)
{
Introduction To Package Manager
Yashobanta Bai
yashobanta.bai@gmail.com
return input.ToUpper();
}
}
}
 Build the project using ,
F:DemoApp> dotnet build
 Package using below command,
F:DemoApp> dotnet pack --configuration release
Now your NuGet package is ready to be published.
Creating a NuGet .NET Framework package using NuGet CLI Tool
 Open Visual Studio, go to File - New and select a .Net Framework Class Library project.
 Write below sample code and build it in release mode.
using System;
namespace SampleNetFrameworkLibrary{
public class Utility {
public string ToUpper(string input)
{
return input.ToUpper();
}
}
}
Introduction To Package Manager
Yashobanta Bai
yashobanta.bai@gmail.com
 Install NuGet.exe
 Create a new folder to hold your package details, let say SampleNetFrameworkPackage.
Inside the new folder create a .nuspec file by using bellow command.
F:SampleNetFrameworkPackage> nuget.exe spec
 This command generate a file Package.nuspec and it is a manifest file that uses XML nodes to describe the
package details such as PackageId, Version, Author etc.
 Open Package.nuspec file and edit the package details such as PackageId, Version, Author etc as per the
requirements.
Sample Package.nuspes looks like below,
<?xml version="1.0"?>
<package >
<metadata>
<id>Package.Test.Yash</id>
<version>1.0.0</version>
<authors>Yashobanta</authors>
<owners>Yashobanta</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Sample description</description>
<releaseNotes>Sample release notes of the package.</releaseNotes>
<copyright>Copyright 2019</copyright>
</metadata>
</package>
 Create another subfolder in the name of "lib" inside "SampleNetFrameworkPackage" and inside the "lib"
folder create a subfolder and name it as per the framework you supported. For an example of you support
.Net4.5 then create a folder name as net45.
 Copy your class library project DLL from the release folder into SampleNetFrameworkPackagelibnet45
folder.
 Create a read me file that contain instructions and additional help regarding your package and it will be
available to the end user just after installing your package.
 Now create the package using the below command
F:SampleNetFrameworkPackage> Nuget.exe pack Package.nuspec
Great! your package is ready now.
Config File Transformations
Some time you may required that when your package is referenced by any application you need to add some
default settings in to the web.config or app.config file, this requirement can be achieved through config file
transformations.
The package creation process will be exactly as mentioned in the above, but we need to add some extra
configuration inside our Package.nuspec file to achieve config transformation.
 Follow the steps mention in the above section i.e " Creating a NuGet .NET Framework package using
NuGet CLI Tool".
Introduction To Package Manager
Yashobanta Bai
yashobanta.bai@gmail.com
 Create a folder name as "content" inside your parent folder that you earlier created to hold your package
details i.e SampleNetFrameworkPackage, and add both app.config.transform and web.config.transform
file.Add the below XML code in both the files.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="TestKey" value="TestValue"/>
</appSettings>
</configuration>
 Then modify the Package.nuspes file to include these transformation file in the package.
<?xml version="1.0"?>
<package >
<metadata>
<id>Package.Test.Yash</id>
<version>1.0.0</version>
<authors>Yashobanta</authors>
<owners>Yashobanta</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Sample description</description>
<releaseNotes>Sample release notes of the package.</releaseNotes>
<copyright>Copyright 2019</copyright>
</metadata>
<files>
<file src="contentweb.config.transform" target="content" />
<file src="contentapp.config.transform" target="content" />
</files>
</package>
 Now when the NuGet package is install in the clients application the key that you had defined in the
transform file will be added to the App.config/web.config file. When the package is uninstalled, the key
will be removed.
Note:
src: The location of the file or files to include.
target: The relative path to the folder within the package where the source files are placed, which must
begin with lib, content, build, or tools.
Reference : https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package#from-a-
convention-based-working-directory
Including Package Dependencies
If your root package is dependent over any other packages then you can define those packages inside the
dependencies section. So when your root package is installed in the client's system, then all the dependent
packages are automatically installed. You can define your project dependencies inside the .nuspec file using
<dependencies> tag.
Introduction To Package Manager
Yashobanta Bai
yashobanta.bai@gmail.com
<?xml version="1.0"?>
<package >
<metadata>
<id>Package.Test.Yash</id>
<version>1.0.0</version>
<authors>Yashobanta</authors>
<owners>Yashobanta</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Sample description</description>
<releaseNotes>Sample release of the package.</releaseNotes>
<copyright>Copyright 2019</copyright>
<dependencies>
<dependency id="Newtonsoft.Json" version="12.0.2" />
</dependencies>
</metadata>
</package>
Note: Now when Package.Test.Yash root package is installed in the client's system, then automatically
Newtonsoft.Json package also going to installed.
Publishing a Package into NuGet public repository.
 Create an NuGet Account by following instructions available in https://www.nuget.org/.
 You can upload packages using NuGet.org web portal or using CLI tools.
Publish package using NuGet.org web portal:
 Sign In to your https://www.nuget.org/. account.
 Go to Manage packages options, it shows you all the packages you had already published.
Introduction To Package Manager
Yashobanta Bai
yashobanta.bai@gmail.com
 To upload a new package you should select upload package option and it provide a easy UI interface
to browse and upload a package.
Congratulations!! You had successfully uploaded your package in to a public repository.It might take
some time to be available to others for consuming it.
Publish package using Dot net core CLI:
 Login to https://www.nuget.org
 Select your user name (on the upper right corner), then select API Keys.
 If you dont have any API keys then create one API key
 Select Create and provide a name for your key, then Select Scopes as Push. Under API Key, enter *
for Glob pattern, then click on Create button to create the API keys.
 Execute the following command to push a package in to the remote repository.
dotnet nuget push MyDemoProject.1.0.0.nupkg -k
oy2b6sukbzvh7d5r2wnqz7ghv7s4utcevgb7ekfbtcli -s https://api.nuget.org/v3/index.json
Note: -k stands for API key and -s stands for Source.
Consume a NuGet package
 Open your .NET project in visual studio , Go to the solution explorer.
 Right click and select Manage NuGet packages.
 Search for your package and install it.
Introduction To Package Manager
Yashobanta Bai
yashobanta.bai@gmail.com
Publishing a Package into a Local repository
 Local NuGet package feeds are nothing but hierarchical folder structures on local networklocal
system.
 Create a new folder in your local system MyLocalNugetRepo and share the folder so that others can
discover this folder.
 You can manually copy the nuget packages into this folder or can use below command to add nuget
packages into this local repository.
nuget add MyDemoProject.1.0.1.nupkg -source HPMyLocalNugetRepo
Consume packages available in the Local repository
 Open your .NET project in visual studio , Go to the solution explorer.
 Right click on your project and select Manage NuGet packages.
 Go to the package source settings
 Go to package source option and click on the plus icon to add the local repository as a source.
 In the Source provide your repository folder location i.e HPMyLocalNugetRepo and press on ok button.
 Now onwards all the packages that you had added inside your local repository folders will be available in
your visual studio package manager
Introduction To Package Manager
Yashobanta Bai
yashobanta.bai@gmail.com
 These packages are available only to those who have access to the repository folder i.e in our case
HPMyLocalNugetRepo.
Publishing a Package into MyGet repository
 MyGet provides both public and private repository/feed.
 So first create an MyGet Account by following instructions available in https://www.myget.org/
 Sign in to the account and click on the new feed button to create a new feed.
 Provide the name and type of the feed
 If you select public type then what ever package you publish can be accessible to anyone. But if you
chose the feed as private then only the authorize candidate can access.
 Go to the MyGet home page to see the list of available feed you have added inside your user account.
 Select the feed in which you want to publish the package.
Introduction To Package Manager
Yashobanta Bai
yashobanta.bai@gmail.com
 Click on add button and select NuGet type package.
 Browse the required package and upload it into the MyGet server.
Consume packages available in the MyGet repository:
 Open your .NET project in visual studio , Go to the solution explorer.
 Right click on your project and select Manage NuGet packages.
 Go to the package source settings
 Go to package source option and click on the plus icon to add the MyGet repository as a source
 In the Source provide your feed url and press on ok button. You can get the feed url from the feed
details section.
Introduction To Package Manager
Yashobanta Bai
yashobanta.bai@gmail.com
 Now onwards all the packages that you had added inside your MyGet feed will be available in your
visual studio package manager and any time you can consume it just by installing from the package
manager
 If you are trying to access and install any private feed packages then package manager will ask your
credentials to validate. So if feed owner provides you access permission then only you can consume the
private feed packages.
Publishing a Package into Azure DevOps repository
Like MyGet we can also use Azure Devops to create a Remote Private NuGet Repository.
 Create an Azure Devops free account by following instructions available in
https://visualstudio.microsoft.com/dev-essentials/.
 Sign in to the AzureDevops account and if you have not added any organization then add one
organization and within the organization add a project.
 Select the required project.
 From the project dashboard select artifacts.
 Click on the NewFeed option.
Introduction To Package Manager
Yashobanta Bai
yashobanta.bai@gmail.com
 Provide the required details and click on the create button to create a feed.
 Click on Connect to feed button and it will show you all the steps required to push a NuGet package in
to the Azure Feed.
Consume packages available in the Azure DevOps repository
 In order to consume the packages, open Visual studio go to the package source option and click on the
plus icon to add the Azure Feed repository url as a source
Introduction To Package Manager
Yashobanta Bai
yashobanta.bai@gmail.com
Creating and publishing a NPM package
NPM is a package manager tool for java script related technologies.
Step 1: We need NPM CLI tool to create an NPM package and NPM tool is distributed as a part of NodeJs.
So check whether node is installed in your system or not.
F:> node --version
F:> npm --version
Step 2: Create a project directory
F:> mkdir mytestnpm
F:> cd mytestnpm
Step 3: Initialise the NPM package
F:mytestnpm> npm init
This command will create a package.json file by taking some manifest details. The file looks like below,
{
"name": " mytestnpmUtility ",
"version": "1.0.0",
"description": "This is my test package.",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "Yashobanta",
"license": "ISC"
}
 main is the important field in the package.json file, it contains the name of the file that would be
loaded when your package is required by another application. By default the value is index.js.
 Name should be unique.
Introduction To Package Manager
Yashobanta Bai
yashobanta.bai@gmail.com
Step 4: Create an index.js file in the root of the project folder and implement the functionality that you want
to share. Whatever methods we exports will be available to the consumer who install our package.
function SayHi() {
return "Wel Come to NPM Demo";
}
module.exports = SayHi;
Step 5: To push NPM package into the NPM repository you first need have an NPM account, you can create
an free account by visiting https://www.npmjs.com.
Login to you account from the command prompt and publish your package using below command in
Administrator mode.
F:mytestnpm> npm login
F:mytestnpm> npm publish
Step 6: Login into you NPM web portal and check your package.
Consume the NPM package
 Create a test directory.
F:> mkdir TestStringUtility
F:> cd TestStringUtility
Introduction To Package Manager
Yashobanta Bai
yashobanta.bai@gmail.com
 Install stringutility package
F:TestStringUtility> npm install stringutility --save
 Create a test file,mytest.js and write the bellow sample code to consume the library.
const SayHi = require('stringutility');
console.log(SayHi());
 Run the node command to execute the code.
F:TestStringUtility> node ./mytest.js

More Related Content

What's hot

Managing dependencies with gradle
Managing dependencies with gradleManaging dependencies with gradle
Managing dependencies with gradleLiviu Tudor
 
Maven with Flex
Maven with FlexMaven with Flex
Maven with FlexPriyank
 
Gradle plugins, take it to the next level
Gradle plugins, take it to the next levelGradle plugins, take it to the next level
Gradle plugins, take it to the next levelEyal Lezmy
 
Hnd201 Building Ibm Lotus Domino Applications With Ajax Plugins
Hnd201 Building Ibm Lotus Domino Applications With Ajax PluginsHnd201 Building Ibm Lotus Domino Applications With Ajax Plugins
Hnd201 Building Ibm Lotus Domino Applications With Ajax Pluginsdominion
 
Gradle plugin, take control of the build
Gradle plugin, take control of the buildGradle plugin, take control of the build
Gradle plugin, take control of the buildEyal Lezmy
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersKostas Saidis
 
Joomla Continuous Delivery with Docker
Joomla Continuous Delivery with DockerJoomla Continuous Delivery with Docker
Joomla Continuous Delivery with DockerJirayut Nimsaeng
 
Continuous Delivery of Containers with Drone & Kontena
Continuous Delivery of Containers with Drone & KontenaContinuous Delivery of Containers with Drone & Kontena
Continuous Delivery of Containers with Drone & KontenaJussi Nummelin
 
Writing Commits for You, Your Friends, and Your Future Self
Writing Commits for You, Your Friends, and Your Future SelfWriting Commits for You, Your Friends, and Your Future Self
Writing Commits for You, Your Friends, and Your Future SelfAll Things Open
 
WTF is GitOps and Why You Should Care?
WTF is GitOps and Why You Should Care?WTF is GitOps and Why You Should Care?
WTF is GitOps and Why You Should Care?Weaveworks
 
Docker Workshop Birthday #3
Docker Workshop Birthday #3Docker Workshop Birthday #3
Docker Workshop Birthday #3Jirayut Nimsaeng
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation ToolIzzet Mustafaiev
 

What's hot (20)

Managing dependencies with gradle
Managing dependencies with gradleManaging dependencies with gradle
Managing dependencies with gradle
 
Gradle
GradleGradle
Gradle
 
Maven with Flex
Maven with FlexMaven with Flex
Maven with Flex
 
Gradle plugins, take it to the next level
Gradle plugins, take it to the next levelGradle plugins, take it to the next level
Gradle plugins, take it to the next level
 
Hnd201 Building Ibm Lotus Domino Applications With Ajax Plugins
Hnd201 Building Ibm Lotus Domino Applications With Ajax PluginsHnd201 Building Ibm Lotus Domino Applications With Ajax Plugins
Hnd201 Building Ibm Lotus Domino Applications With Ajax Plugins
 
Gradle plugin, take control of the build
Gradle plugin, take control of the buildGradle plugin, take control of the build
Gradle plugin, take control of the build
 
Gradle presentation
Gradle presentationGradle presentation
Gradle presentation
 
Gradle
GradleGradle
Gradle
 
Android presentation - Gradle ++
Android presentation - Gradle ++Android presentation - Gradle ++
Android presentation - Gradle ++
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Python+gradle
Python+gradlePython+gradle
Python+gradle
 
{py}gradle
{py}gradle{py}gradle
{py}gradle
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java Developers
 
Joomla Continuous Delivery with Docker
Joomla Continuous Delivery with DockerJoomla Continuous Delivery with Docker
Joomla Continuous Delivery with Docker
 
Continuous Delivery of Containers with Drone & Kontena
Continuous Delivery of Containers with Drone & KontenaContinuous Delivery of Containers with Drone & Kontena
Continuous Delivery of Containers with Drone & Kontena
 
Writing Commits for You, Your Friends, and Your Future Self
Writing Commits for You, Your Friends, and Your Future SelfWriting Commits for You, Your Friends, and Your Future Self
Writing Commits for You, Your Friends, and Your Future Self
 
WTF is GitOps and Why You Should Care?
WTF is GitOps and Why You Should Care?WTF is GitOps and Why You Should Care?
WTF is GitOps and Why You Should Care?
 
Docker Workshop Birthday #3
Docker Workshop Birthday #3Docker Workshop Birthday #3
Docker Workshop Birthday #3
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation Tool
 
Git Overview
Git OverviewGit Overview
Git Overview
 

Similar to Introduction to package manager

Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Justin James
 
NuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxNuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxKnoldus Inc.
 
ConFoo - NuGet beyond Hello World
ConFoo - NuGet beyond Hello WorldConFoo - NuGet beyond Hello World
ConFoo - NuGet beyond Hello WorldMaarten Balliauw
 
Hosting your own NuGet private repository
Hosting your own NuGet private repositoryHosting your own NuGet private repository
Hosting your own NuGet private repositoryYu GUAN
 
NuGet beyond Hello World - DotNext Piter 2017
NuGet beyond Hello World - DotNext Piter 2017NuGet beyond Hello World - DotNext Piter 2017
NuGet beyond Hello World - DotNext Piter 2017Maarten Balliauw
 
DevTools Package Development
 DevTools Package Development DevTools Package Development
DevTools Package DevelopmentSagar Deogirkar
 
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
[Patel] SPFx: An ISV Insight into latest Microsoft's customization modelEuropean Collaboration Summit
 
Creating an nuget package for EPiServer
Creating an nuget package for EPiServerCreating an nuget package for EPiServer
Creating an nuget package for EPiServerPaul Graham
 
Hacking the Explored App by Adding Custom Code (UI5con 2016)
Hacking the Explored App by Adding Custom Code (UI5con 2016)Hacking the Explored App by Adding Custom Code (UI5con 2016)
Hacking the Explored App by Adding Custom Code (UI5con 2016)Nabi Zamani
 
Pragmatic software development in kdb+
Pragmatic software development in kdb+Pragmatic software development in kdb+
Pragmatic software development in kdb+Ajay Rathore
 
Native development kit (ndk) introduction
Native development kit (ndk)  introductionNative development kit (ndk)  introduction
Native development kit (ndk) introductionRakesh Jha
 
How create react app help in creating a new react applications
How create react app help in creating a new react applications How create react app help in creating a new react applications
How create react app help in creating a new react applications Concetto Labs
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using SwiftDiego Freniche Brito
 
ReactJS software installation
ReactJS software installationReactJS software installation
ReactJS software installationHopeTutors1
 
How to install ReactJS software
How to install ReactJS software How to install ReactJS software
How to install ReactJS software VigneshVijay21
 
WP7 HUB_Introducción a Visual Studio
WP7 HUB_Introducción a Visual StudioWP7 HUB_Introducción a Visual Studio
WP7 HUB_Introducción a Visual StudioMICTT Palma
 
Mastering node.js, part 1 - introduction
Mastering node.js, part 1 - introductionMastering node.js, part 1 - introduction
Mastering node.js, part 1 - introductioncNguyn826690
 
Overview of Node JS
Overview of Node JSOverview of Node JS
Overview of Node JSJacob Nelson
 

Similar to Introduction to package manager (20)

Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...
 
NuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxNuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptx
 
ConFoo - NuGet beyond Hello World
ConFoo - NuGet beyond Hello WorldConFoo - NuGet beyond Hello World
ConFoo - NuGet beyond Hello World
 
Hosting your own NuGet private repository
Hosting your own NuGet private repositoryHosting your own NuGet private repository
Hosting your own NuGet private repository
 
NuGet beyond Hello World - DotNext Piter 2017
NuGet beyond Hello World - DotNext Piter 2017NuGet beyond Hello World - DotNext Piter 2017
NuGet beyond Hello World - DotNext Piter 2017
 
DevTools Package Development
 DevTools Package Development DevTools Package Development
DevTools Package Development
 
Django
DjangoDjango
Django
 
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
 
Creating an nuget package for EPiServer
Creating an nuget package for EPiServerCreating an nuget package for EPiServer
Creating an nuget package for EPiServer
 
Hacking the Explored App by Adding Custom Code (UI5con 2016)
Hacking the Explored App by Adding Custom Code (UI5con 2016)Hacking the Explored App by Adding Custom Code (UI5con 2016)
Hacking the Explored App by Adding Custom Code (UI5con 2016)
 
Pragmatic software development in kdb+
Pragmatic software development in kdb+Pragmatic software development in kdb+
Pragmatic software development in kdb+
 
Native development kit (ndk) introduction
Native development kit (ndk)  introductionNative development kit (ndk)  introduction
Native development kit (ndk) introduction
 
How create react app help in creating a new react applications
How create react app help in creating a new react applications How create react app help in creating a new react applications
How create react app help in creating a new react applications
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
 
ReactJS software installation
ReactJS software installationReactJS software installation
ReactJS software installation
 
How to install ReactJS software
How to install ReactJS software How to install ReactJS software
How to install ReactJS software
 
WP7 HUB_Introducción a Visual Studio
WP7 HUB_Introducción a Visual StudioWP7 HUB_Introducción a Visual Studio
WP7 HUB_Introducción a Visual Studio
 
Mastering node.js, part 1 - introduction
Mastering node.js, part 1 - introductionMastering node.js, part 1 - introduction
Mastering node.js, part 1 - introduction
 
Technology Radar Talks - NuGet
Technology Radar Talks - NuGetTechnology Radar Talks - NuGet
Technology Radar Talks - NuGet
 
Overview of Node JS
Overview of Node JSOverview of Node JS
Overview of Node JS
 

Recently uploaded

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Recently uploaded (20)

Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

Introduction to package manager

  • 1. Introduction To Package Manager Yashobanta Bai yashobanta.bai@gmail.com Agenda: Creating, Publishing and Consuming NuGet Package.  Introduction to Package Manager.  Packaging Steps.  Creating a NuGet Core package using Visual Studio IDE.  Creating a NuGet Core package using .NET CLI Tool.  Creating a NuGet .NET Framework package using NuGet CLI Tool.  Config file transformations.  Including package dependencies using .nuspec file..  Publishing a Package into NuGet public repository using NuGet.org web interface.  Publish package into NuGet public repository using Dot net core CLI.  Publishing a Package into a Local repository.  How to consume packages available in the Local repository:  Publishing a Package into MyGet repository.  How to consume packages available in the MyGet repository.  Publishing a Package into Azure DevOps repository.  How to create and publish a NPM package? What is a package manager? Package Manager is a tool used to simplify the process of installing, configuring, upgrading and removing of software packages. Why we need a Package Manager? When we want to consume any library from our code we generally follow certain steps such as,  Search for the required library.  Install the library.  Add the reference to the DLL.  Configure the library if needed. After some day if we need to update our library because we found some critical bug or security hole then we need to follow some steps to remove it from the current project and again follow above repeated steps to refer the new library. As day by day the amount of libraries available for any given language or technology are increases and in a given software project we may used hundreds of libraries, so it is very difficult to manually manage the library packages . So we required a proper tool to manage all our packages. Popular Package Manager Tool: NuGet: Package manager for the Microsoft development platform. NPM: package manager for Node.js and JavaScript Reference : https://www.nuget.org/ , https://www.npmjs.com/ What is a NuGet Package? The NuGet package is just a ZIP file with a extension of .nupkg and is contains compiled code ,other supported file require for the package, and a descriptive manifest that includes information like, the package's version number, Package Id,author , company etc. Reference: https://docs.microsoft.com/en-us/nuget/reference/nuspec Packaging Steps: There are some basic steps we need to follow for packaging and this process is common for mostly all type packages like NuGet, npm etc. Step 1: Write required source code  Write the code to implement the Business requirements and test the library thoroughly to make sure that its working as expected.
  • 2. Introduction To Package Manager Yashobanta Bai yashobanta.bai@gmail.com  You are free to create a .NET Framework libraries , .NET Core libraries etc. Step 2: Create a package.  To create a package you can use any NuGet client tool such as Visual Studio IDE, dotnet.exe or nuget.exe  dotnet.exe tool is for .NET Core libraries. Step 3: Publish the package into a package repository. As per your business requirements you can select any type of repository.  Public Repository: If you want that your package should available to everyone then you should chose a public repository like Nuget.org.  Private Repository: There might be some scenarios where you might want to release packages to only a limited audience or you want some restriction over the package uses then you should go for a private repository. It may be a local private repository or remote private repository. Local Private Repository: Local NuGet package feeds are simply a collections of folder on your local network. Remote Private Repository: There are some NuGet hosting providers who provides services for private repository and popular examples are MyGet and Azure DevOps. Step 4: Consume the package.  Consumer application can browse the packages using a package manager tool and consume it where ever required. Creating a NuGet Core package using Visual Studio IDE  Open Visual Studio, go to File - New and select a .Net Core Class Library project.  Write some sample code. using System; namespace SampleLibrary { public class Utility { public string ToUpper(string input) { return input.ToUpper(); } } }
  • 3. Introduction To Package Manager Yashobanta Bai yashobanta.bai@gmail.com  Right-click on the project, choose Properties and go to the package tab.  Check the check box at the top and then fill in the package information as required. Package ID This is a unique identifier used to identify your package uniquely.. Version This is a version of the package like 1.0.0. Author This field holds authors of the package. owners Generally Author and owner both contains same value i.e creator of the package. iconUrl We can specify an icon for the package. The size of the image should be a 32x32 pixel png image with transparent background. copyright Specify copyright details for the package. tags Tags are nothing but keywords and can be used to search the package. releaseNotes This going to hold the release notes of the project. description As the name suggests, this is a long description of the package.  Build the class library in the release mode. Congratulations!! You are ready with your first NuGet package. Now you can publish into any type of NuGet repository. Creating a NuGet Core package using .NET CLI Tool  Create a .net core library using CLI F:> mkdir DemoApp F:> dotnet new classlib -n SampleUtility -o DemoApp -n stands for name of the class library and -o stands for output directory  Open the project file in any supported editor such as Visual Studio Code and write your sample code. using System; namespace SampleLibrary { public class Utility { public string ToUpper(string input) {
  • 4. Introduction To Package Manager Yashobanta Bai yashobanta.bai@gmail.com return input.ToUpper(); } } }  Build the project using , F:DemoApp> dotnet build  Package using below command, F:DemoApp> dotnet pack --configuration release Now your NuGet package is ready to be published. Creating a NuGet .NET Framework package using NuGet CLI Tool  Open Visual Studio, go to File - New and select a .Net Framework Class Library project.  Write below sample code and build it in release mode. using System; namespace SampleNetFrameworkLibrary{ public class Utility { public string ToUpper(string input) { return input.ToUpper(); } } }
  • 5. Introduction To Package Manager Yashobanta Bai yashobanta.bai@gmail.com  Install NuGet.exe  Create a new folder to hold your package details, let say SampleNetFrameworkPackage. Inside the new folder create a .nuspec file by using bellow command. F:SampleNetFrameworkPackage> nuget.exe spec  This command generate a file Package.nuspec and it is a manifest file that uses XML nodes to describe the package details such as PackageId, Version, Author etc.  Open Package.nuspec file and edit the package details such as PackageId, Version, Author etc as per the requirements. Sample Package.nuspes looks like below, <?xml version="1.0"?> <package > <metadata> <id>Package.Test.Yash</id> <version>1.0.0</version> <authors>Yashobanta</authors> <owners>Yashobanta</owners> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Sample description</description> <releaseNotes>Sample release notes of the package.</releaseNotes> <copyright>Copyright 2019</copyright> </metadata> </package>  Create another subfolder in the name of "lib" inside "SampleNetFrameworkPackage" and inside the "lib" folder create a subfolder and name it as per the framework you supported. For an example of you support .Net4.5 then create a folder name as net45.  Copy your class library project DLL from the release folder into SampleNetFrameworkPackagelibnet45 folder.  Create a read me file that contain instructions and additional help regarding your package and it will be available to the end user just after installing your package.  Now create the package using the below command F:SampleNetFrameworkPackage> Nuget.exe pack Package.nuspec Great! your package is ready now. Config File Transformations Some time you may required that when your package is referenced by any application you need to add some default settings in to the web.config or app.config file, this requirement can be achieved through config file transformations. The package creation process will be exactly as mentioned in the above, but we need to add some extra configuration inside our Package.nuspec file to achieve config transformation.  Follow the steps mention in the above section i.e " Creating a NuGet .NET Framework package using NuGet CLI Tool".
  • 6. Introduction To Package Manager Yashobanta Bai yashobanta.bai@gmail.com  Create a folder name as "content" inside your parent folder that you earlier created to hold your package details i.e SampleNetFrameworkPackage, and add both app.config.transform and web.config.transform file.Add the below XML code in both the files. <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="TestKey" value="TestValue"/> </appSettings> </configuration>  Then modify the Package.nuspes file to include these transformation file in the package. <?xml version="1.0"?> <package > <metadata> <id>Package.Test.Yash</id> <version>1.0.0</version> <authors>Yashobanta</authors> <owners>Yashobanta</owners> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Sample description</description> <releaseNotes>Sample release notes of the package.</releaseNotes> <copyright>Copyright 2019</copyright> </metadata> <files> <file src="contentweb.config.transform" target="content" /> <file src="contentapp.config.transform" target="content" /> </files> </package>  Now when the NuGet package is install in the clients application the key that you had defined in the transform file will be added to the App.config/web.config file. When the package is uninstalled, the key will be removed. Note: src: The location of the file or files to include. target: The relative path to the folder within the package where the source files are placed, which must begin with lib, content, build, or tools. Reference : https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package#from-a- convention-based-working-directory Including Package Dependencies If your root package is dependent over any other packages then you can define those packages inside the dependencies section. So when your root package is installed in the client's system, then all the dependent packages are automatically installed. You can define your project dependencies inside the .nuspec file using <dependencies> tag.
  • 7. Introduction To Package Manager Yashobanta Bai yashobanta.bai@gmail.com <?xml version="1.0"?> <package > <metadata> <id>Package.Test.Yash</id> <version>1.0.0</version> <authors>Yashobanta</authors> <owners>Yashobanta</owners> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Sample description</description> <releaseNotes>Sample release of the package.</releaseNotes> <copyright>Copyright 2019</copyright> <dependencies> <dependency id="Newtonsoft.Json" version="12.0.2" /> </dependencies> </metadata> </package> Note: Now when Package.Test.Yash root package is installed in the client's system, then automatically Newtonsoft.Json package also going to installed. Publishing a Package into NuGet public repository.  Create an NuGet Account by following instructions available in https://www.nuget.org/.  You can upload packages using NuGet.org web portal or using CLI tools. Publish package using NuGet.org web portal:  Sign In to your https://www.nuget.org/. account.  Go to Manage packages options, it shows you all the packages you had already published.
  • 8. Introduction To Package Manager Yashobanta Bai yashobanta.bai@gmail.com  To upload a new package you should select upload package option and it provide a easy UI interface to browse and upload a package. Congratulations!! You had successfully uploaded your package in to a public repository.It might take some time to be available to others for consuming it. Publish package using Dot net core CLI:  Login to https://www.nuget.org  Select your user name (on the upper right corner), then select API Keys.  If you dont have any API keys then create one API key  Select Create and provide a name for your key, then Select Scopes as Push. Under API Key, enter * for Glob pattern, then click on Create button to create the API keys.  Execute the following command to push a package in to the remote repository. dotnet nuget push MyDemoProject.1.0.0.nupkg -k oy2b6sukbzvh7d5r2wnqz7ghv7s4utcevgb7ekfbtcli -s https://api.nuget.org/v3/index.json Note: -k stands for API key and -s stands for Source. Consume a NuGet package  Open your .NET project in visual studio , Go to the solution explorer.  Right click and select Manage NuGet packages.  Search for your package and install it.
  • 9. Introduction To Package Manager Yashobanta Bai yashobanta.bai@gmail.com Publishing a Package into a Local repository  Local NuGet package feeds are nothing but hierarchical folder structures on local networklocal system.  Create a new folder in your local system MyLocalNugetRepo and share the folder so that others can discover this folder.  You can manually copy the nuget packages into this folder or can use below command to add nuget packages into this local repository. nuget add MyDemoProject.1.0.1.nupkg -source HPMyLocalNugetRepo Consume packages available in the Local repository  Open your .NET project in visual studio , Go to the solution explorer.  Right click on your project and select Manage NuGet packages.  Go to the package source settings  Go to package source option and click on the plus icon to add the local repository as a source.  In the Source provide your repository folder location i.e HPMyLocalNugetRepo and press on ok button.  Now onwards all the packages that you had added inside your local repository folders will be available in your visual studio package manager
  • 10. Introduction To Package Manager Yashobanta Bai yashobanta.bai@gmail.com  These packages are available only to those who have access to the repository folder i.e in our case HPMyLocalNugetRepo. Publishing a Package into MyGet repository  MyGet provides both public and private repository/feed.  So first create an MyGet Account by following instructions available in https://www.myget.org/  Sign in to the account and click on the new feed button to create a new feed.  Provide the name and type of the feed  If you select public type then what ever package you publish can be accessible to anyone. But if you chose the feed as private then only the authorize candidate can access.  Go to the MyGet home page to see the list of available feed you have added inside your user account.  Select the feed in which you want to publish the package.
  • 11. Introduction To Package Manager Yashobanta Bai yashobanta.bai@gmail.com  Click on add button and select NuGet type package.  Browse the required package and upload it into the MyGet server. Consume packages available in the MyGet repository:  Open your .NET project in visual studio , Go to the solution explorer.  Right click on your project and select Manage NuGet packages.  Go to the package source settings  Go to package source option and click on the plus icon to add the MyGet repository as a source  In the Source provide your feed url and press on ok button. You can get the feed url from the feed details section.
  • 12. Introduction To Package Manager Yashobanta Bai yashobanta.bai@gmail.com  Now onwards all the packages that you had added inside your MyGet feed will be available in your visual studio package manager and any time you can consume it just by installing from the package manager  If you are trying to access and install any private feed packages then package manager will ask your credentials to validate. So if feed owner provides you access permission then only you can consume the private feed packages. Publishing a Package into Azure DevOps repository Like MyGet we can also use Azure Devops to create a Remote Private NuGet Repository.  Create an Azure Devops free account by following instructions available in https://visualstudio.microsoft.com/dev-essentials/.  Sign in to the AzureDevops account and if you have not added any organization then add one organization and within the organization add a project.  Select the required project.  From the project dashboard select artifacts.  Click on the NewFeed option.
  • 13. Introduction To Package Manager Yashobanta Bai yashobanta.bai@gmail.com  Provide the required details and click on the create button to create a feed.  Click on Connect to feed button and it will show you all the steps required to push a NuGet package in to the Azure Feed. Consume packages available in the Azure DevOps repository  In order to consume the packages, open Visual studio go to the package source option and click on the plus icon to add the Azure Feed repository url as a source
  • 14. Introduction To Package Manager Yashobanta Bai yashobanta.bai@gmail.com Creating and publishing a NPM package NPM is a package manager tool for java script related technologies. Step 1: We need NPM CLI tool to create an NPM package and NPM tool is distributed as a part of NodeJs. So check whether node is installed in your system or not. F:> node --version F:> npm --version Step 2: Create a project directory F:> mkdir mytestnpm F:> cd mytestnpm Step 3: Initialise the NPM package F:mytestnpm> npm init This command will create a package.json file by taking some manifest details. The file looks like below, { "name": " mytestnpmUtility ", "version": "1.0.0", "description": "This is my test package.", "main": "index.js", "scripts": { "test": "echo "Error: no test specified" && exit 1" }, "author": "Yashobanta", "license": "ISC" }  main is the important field in the package.json file, it contains the name of the file that would be loaded when your package is required by another application. By default the value is index.js.  Name should be unique.
  • 15. Introduction To Package Manager Yashobanta Bai yashobanta.bai@gmail.com Step 4: Create an index.js file in the root of the project folder and implement the functionality that you want to share. Whatever methods we exports will be available to the consumer who install our package. function SayHi() { return "Wel Come to NPM Demo"; } module.exports = SayHi; Step 5: To push NPM package into the NPM repository you first need have an NPM account, you can create an free account by visiting https://www.npmjs.com. Login to you account from the command prompt and publish your package using below command in Administrator mode. F:mytestnpm> npm login F:mytestnpm> npm publish Step 6: Login into you NPM web portal and check your package. Consume the NPM package  Create a test directory. F:> mkdir TestStringUtility F:> cd TestStringUtility
  • 16. Introduction To Package Manager Yashobanta Bai yashobanta.bai@gmail.com  Install stringutility package F:TestStringUtility> npm install stringutility --save  Create a test file,mytest.js and write the bellow sample code to consume the library. const SayHi = require('stringutility'); console.log(SayHi());  Run the node command to execute the code. F:TestStringUtility> node ./mytest.js