Thursday, December 26, 2019

How to convert a .net assembly into nuget package

For creating a new Nuget Package from scratch is given in the below link:

https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package-using-visual-studio?tabs=netcore-cli

On the other hand, if we have an assembly already (may be from a third party), but have to add it into our local for development. On the other hand, want the same assembly into our project specific Nuget feed, then we may need to convert an existing dll into a nuget package file.

This blog helps you in understanding how to convert a .net assembly into a nuget package.

Lets take an example use case. In sitecore, we have Sitecore Publishing Service. This is not yet into Sitecore Nuget feed, however, if we need to use this package and move the libraries across environments through CI CD pipeline, we would need these libraries in Custom Nuget Feed.

Step 1: Identify the library that has to be packaged,

In our case, its Sitecore Publishing Service libraries,

Step 2: Now create a package manifest in .nuspec XML file.

What is a package manifest and what exactly is .nuspec?

Created the below rile for package manifest, with .nuspec file.

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
    <metadata>
        <id>XYZ.Sitecore.Publishing.Service</id>
        <version>9.2.0</version>
        <authors>Gopi Sivanappan Vasanthi</authors>
        <owners>Sitecore</owners>
        <projectUrl>https://dev.sitecore.net/Downloads/Sitecore_Publishing_Service_Module.aspx</projectUrl>
        <license type="expression">Sitecore</license>
        <iconUrl>http://github.com/contoso/UsefulStuff/nuget_icon.png</iconUrl>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <releaseNotes></releaseNotes>
        <description>Sitecore Publishing Service Module - Required for connecting Sitecore Publishing Service and Sitecore</description>
        <copyright>Copyright ©2019 Sitecore Corporation</copyright>
        <tags>Sitecore Publishing Service Module</tags>
        <dependencies>
        </dependencies>
    </metadata>
    <files>
    </files>
</package>


Step 3: 

No comments: