Skip to content

Instantly share code, notes, and snippets.

@icodeintx
Created December 14, 2022 06:20
Show Gist options
  • Save icodeintx/7984b4f2cc2884b9d41a44580a3749d1 to your computer and use it in GitHub Desktop.
Save icodeintx/7984b4f2cc2884b9d41a44580a3749d1 to your computer and use it in GitHub Desktop.

Add these three (indented) lines to your csproj file

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
	  <PackAsTool>true</PackAsTool>
	  <ToolCommandName>gtconfig</ToolCommandName>
	  <PackageOutputPath>./nupkg</PackageOutputPath>
  </PropertyGroup>

After successful build run

dotnet pack

This will build the package in the output path set in <PackageOutputPath>

The last step is to install this package

dotnet tool install --global --add-source ./nupkg GtConfig

Since we are installing from a local package we must include the --add-source command with the package location as the argument along with the final argument which is the namespace of the project.

Nick Chapsas has a fantastic video on YouTube on this: https://www.youtube.com/watch?v=JNDgcBDZPkU

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment