Ellerbach / docfx-companion-tools

A suite of tools, pipelines templates to take the very best of DocFX
MIT License
64 stars 18 forks source link

Include Multiplatform Artifacts in Builds #11

Closed deckerbd closed 1 year ago

deckerbd commented 2 years ago

Hey there, love the utilities!

I routinely hop between Windows and macOS, and noticed while there's binaries published for Windows in this repo and on Chocolatey, there's none published for macOS or on Homebrew. Currently I'm pulling the source and rebuilding against macOS instead of Windows. I was wondering if in addition to Windows binaries, if there could be consideration in publishing release artifacts for macOS and Linux going forward as well. I can help with a PR if desired.

Ellerbach commented 2 years ago

Hi @deckerbd, I guess it's something we can do. Have Windows, MacOS and Linux artifact published as well. That will require to adjust a bit the workflow. On the to do list but please don't expect anything in a short period of time!

cathalnoonan commented 1 year ago

Would you consider releasing these as dotnet tools? This would be an alternative to building and publishing multi-platform builds that instead relies on the dotnet sdk installed on the consumer's machine (Windows/macOS/Linux).

The docs for creating a dotnet tool suggest adding the dotnet-tool related properties to the .csproj files, but this approach might affect the existing build process used in this repo to build/publish the .exes to chocolatey.

It's also possible to pass these dotnet-tool related properties to the dotnet pack command using the -p argument (without modifying the .csproj files). See below as an example. ~https://github.com/cathalnoonan/docfx-companion-tools/blob/e5fd18e9462b3b8fe23e744e5ca25ed60fdc6f6a/pack_dotnet_tools.sh~ (this fork has been deleted after the issue was closed, relevant file contents copied below).

#!/usr/bin/env bash
set -e

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# Clean previous nuget packages (if they exist)
rm -rf $SCRIPT_DIR/dist/*

SOLUTION_FILES=( $SCRIPT_DIR/src/**/*.sln )
for solution_file in "${SOLUTION_FILES[@]}"
do
    solution_name=$( basename $solution_file )
    solution_name="${solution_name%.*}"

    # Use the solution name as the name of the dotnet tool
    # Pass arguments to dotnet pack so a dotnet tool is published
    dotnet pack "$solution_file" -c Release -p:PackAsTool=true -p:ToolCommandName=$solution_name -p:PackageOutputPath=$SCRIPT_DIR/dist
done

After packing the nupkgs, the packages can be pushed using dotnet nuget push (with an API key for authenticating to NuGet.org).

Assuming the tools are published to NuGet, the consumers would install the parts they need by running:

# (replace DocFxTocGenerator below with the other tools as necessary)

# Install the tool locally in the current folder
dotnet new tool-manifest
dotnet tool install DocFxTocGenerator

# Install the tool globally
dotnet tool install -g DocFxTocGenerator
Ellerbach commented 1 year ago

@cathalnoonan, yes definitely. Let me have a look on how to release those like this quickly. @mtirion I will have a look at this.

Ellerbach commented 1 year ago

@cathalnoonan it's done:

image

You can install each tool separately. Each tool is using its own name.

Ellerbach commented 1 year ago

And all works as expected on a Mac:

image

You can run properly the tools:

image

So @deckerbd you just need to have .NET 6.0 or higher installed and add the ~/.dotnet/tool to your path and you can enjoy all the tools!