DEV Community

Emily
Emily

Posted on

Publishing shinny-ssg Nuget Package

In the last lab of OSD600, I have a chance to publish and release my static site generation application. I chose Nuget.org as my package registry. I have always loved Microsoft documentation as it is clear and easy to follow. This time, I simply followed their instructions and got my package available here.

Pack

To start, I needed to set the application's PropertyGroup in the project files

    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>netcoreapp3.1</TargetFramework>
        <RootNamespace>shinny_ssg</RootNamespace>
        <PackAsTool>true</PackAsTool>
        <PackageId>shinny_ssg</PackageId>
        <Version>1.0.1</Version>
        <Authors>Emily Phan</Authors>
        <PackageOutputPath>./bin</PackageOutputPath>
        <IsPackable>true</IsPackable>
        <RunPostBuildEvent>Always</RunPostBuildEvent>
    </PropertyGroup>
Enter fullscreen mode Exit fullscreen mode

Then you can use the command line to pack the package:

dotnet pack
Enter fullscreen mode Exit fullscreen mode

This command generated a .nugkp in the /bin folder.

Publish

The next part is publishing the package to nuget.org.
To prepare for that, I created a Nuget account and retrieved the API key. This key is used to identify your account to the Nuget Gallery.
After that, I ran this command to publish Shinny-ssg

dotnet nuget push shinny_ssg.1.0.1.nupkg --api-key <token> --source https://api.nuget.org/v3/index.json
Enter fullscreen mode Exit fullscreen mode

And that was it, my tool was ready to use.

Testing

I asked one of my friends to test the tools. We have found a bug in my application. When she ran shinny-ssg -v , she got Multiple options with name "v" found. This is usually due to nested options. I realized that I did implemented the -v|--version twice and I did not specify it right in my Options class. I will fix this issue and update the version.

Publishing the package is a happy ending for the project I have worked on the last 2 months. After this, I understand more about a project's lifecycle: developing, testing and publishing.

Discussion (0)