DEV Community

Emily
Emily

Posted on

3 1

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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay