0
votes

I need to create a self-contained .net core (3.1 in my case) app and to pack & publish using chocolatey so it can be installed and used.

I'm using Azure DevOps and have a feed on my own where I'm supposed to publish the chocolatey package.

The objective is to do this in the build pipeline, so, among other tasks I have:

  • dotnet publish task: creates the self-contained executable
  • chocolatey pack task: creates the .nupkg from a very simplistic .nuspec (only mandatory fields) I created.

My current problem is that the .nupkg file created contains always the project files and not the executable generated.

To try and work around it I even made the chocolatey pack's task work directory the same as the dotnet publish's task output one.

enter image description here

enter image description here

What am I missing? Is there another approach?

2

2 Answers

0
votes

Azure DevOps: publish self-contained .net Core app with Chocolatey

It depends on whether you include the contained executable file in your .nuspec file.

If we include the contained executable file in the .nuspec file, chocolatey will create the .nupkg include the contained executable file, like:

  <files>
    <file src="IngestCanonicLtesConsole\ContainedExecutable.exe" target="Tools\ContainedExecutable.exe" />
  </files>

We could add this contained executable file in the package:

enter image description here

So, if we are only include the mandatory fields without the <files>contained executable </files>, it will not include the contained executable file.

Besides, we need to include the contained executable file in the .nuspec file, we could change the output of the dotnet build to $(System.DefaultWorkingDirectory)\IngestCanonicLtesConsole, so that we could use the relative path in the .nuspec file.

Please check the document .nuspec reference for some more details.

0
votes

After a few tests I realized that the chocolatey pack will "pack" all files that in exist in the same folder as the ".nuspec". Not sure this is because I don't set anything on tool.

Basically, my solution was to copy my ".nuspec" file to the folder where my executable was.