Skip to content

Instantly share code, notes, and snippets.

@lfmundim
Last active August 8, 2018 21:22
Show Gist options
  • Save lfmundim/b80900ac1e93daeba836fd7afb277da3 to your computer and use it in GitHub Desktop.
Save lfmundim/b80900ac1e93daeba836fd7afb277da3 to your computer and use it in GitHub Desktop.
Notes on how to manage NuGet package publishing

NuGet Management

Notes on commands and configs to manage NuGet packages

Template - Setting Up

Folder structure

📁Blip.Api.Template
    📁content
        📁.template.config
            📃template.json
        💻{project source code}
        ...
        💻{project source code}
    📃Blip.Api.Template.nuspec

.nuspec file

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>Blip.Api.Template</id>
    <version>1.0.5</version>
    <description>
      Starts a new BLiP API project
    </description>
    <authors>Lucas Mundim</authors>
    <packageTypes>
      <packageType name="Template" />
    </packageTypes>
  </metadata>
</package>

template.json file

{
  "$schema": "http://json.schemastore.org/template",
  "author": "Lucas Mundim",
  "classifications": [ "API", "ASP.NET Core", "BLiP" ],
  "identity": "Blip.Api.Template",
  "name": "BLiP API Template",
  "shortName": "blip-api",
  "tags":{
    "language": "C#" 
  },
  "sourceName": "Blip.Api.Template",
  "preferNameDirectory": true // replaces sourceName's value on files with the folder name
}

Packing

Pack

nuget pack Blip.Api.Template.nuspec

Template installing, using and uninstalling

Installing

dotnet new -i Blip.Api.Template.nupkg

Using

dotnet new blip-api

Uninstalling

dotnet new -u Blip.Api.Template

NuGet Publishing

(after packing)
nuget push Blip.Api.Template.1.0.x.nupkg [KEY] -Source https://api.nuget.org/v3/index.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment