Search code examples
c#windows-10.net-corechocolatey

How to create a chocolatey package for a .NET Core cli application?


I have a very basic cli application(that basically prints "hello world") written in C# and that uses the .net core runtime.

I tried to create a chocolatey package by:

  1. running choco new hcli
  2. modifing the generated .nuspec file manually to supply info(version, author...)
  3. running choco pack

This produced a .nupkg file, when I run choco install hcli.0.0.1.nupkg I get ERROR: This package does not support 64 bit architecture.

I am suspecting that chocolatey does not support project.json based projects, the documentation does not mention anything about .net core.

What am I doing wrong?

project.json file:

{
  "version": "0.1.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true,
    "outputName": "hcli"
  },
  "dependencies": {},
  "frameworks": {
    "netcoreapp1.1": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "version": "1.1.0"
        }
      },
      "imports": "dnxcore50"
    }
  },
  "runtimes": {
    "win7-x64": {}
  }
}

Solution

  • Chocolatey does not support visual studio projects nor project.json at the time of this post.

    Fix the error

    What you are seeing is a pretty common error if you have not set up or adjusted any of the packaging.

    Have you reviewed the contents of tools\chocolateyInstall.ps1 after you generated the packaging? I would review and adjust those automation scripts that were generated (and review the readme).

    If you don't need the automation scripts, simply remove them and have your binaries in the package.

    As you have indicated, there is a much more drawn out article at https://chocolatey.org/docs/create-packages

    Alternative Option - Use NuGet to pack

    You can always look to use NuGet to generate the package and then consume it with Chocolatey. As long as it is compatible with NuGet v2 (currently), you should be good to go. The other aspect of that is that if you have dependencies at the DLL level, please include them in the packaging - dependencies are really at the application level. Like a dependency on dotnetcore package.