Question: How to fetch the nugetforunity packages during CI/CD in a github action?
gotchipete opened this issue · comments
Has anyone done this?
Hi,
In the CI of NuGetForUnity we use it to verify that it works.
NuGetForUnity/.github/workflows/main.yml
Lines 207 to 211 in 03353e7
Note: When you do it in your own CI you don't need the
--add-source
. Normally you would install the tool locally and than do dotnet tool restore
(just look at the official documentation for global tools).See also the documentation in the ReadMe.md. I thought that this is "enough" to understand how to use it in CI/CD. Do you have any suggestion on how we can improve the documentation?
Not sure yet how to improve it but I'm trying to follow it unsuccessfully thus far (including the comments in this thread).. tried multiple things, most recent is
locally:
dotnet new tool-manifest
dotnet tool install NuGetForUnity.Cli
# (succeeds)
in build action (after checkout - trying to do what you say here: #522 (comment))
# setup .NET for package resolution
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: 2.1
# Install NuGetForUnity.Cli
- name: Restore dotnet tool - NuGetForUnity.Cli
run: dotnet tool restore
# Restore NuGetForUnity packages
- name: Restore NuGetForUnity packages
run: dotnet nugetforunity restore ./apps/myapp
... build output gives me (from the Install NuGetForUnity.Cli step)
Required command was not provided.
tnet tool [options] [command]
Options:
-h, --help Show command line help.
Commands:
install <PACKAGE_ID> Install a tool for use on the command line.
uninstall <PACKAGE_ID> Uninstall a tool from the current development environment.
update <PACKAGE_ID> Update a tool to the latest stable version.
list List tools installed in the current development environment.
Error: Process completed with exit code 1.
aha this is working but i have an issue with one of my packages now. @JoC0de if there is a way i can improve this lmk
# setup .NET for package resolution
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0
# Install NuGetForUnity.Cli
- name: Restore dotnet tool - NuGetForUnity.Cli
run: dotnet new tool-manifest; dotnet tool install NuGetForUnity.Cli
# Restore NuGetForUnity packages
- name: Restore NuGetForUnity packages
run: dotnet nugetforunity restore ./apps/myapp
dotnet new tool-manifest
creates a file .config/dotnet-tools.json
see e.g. .config/dotnet-tools.json.
wenn you commit this file to your repository, so it is available to the GitHub action, you can call dotnet tool restore
-> it will restore all tools defined in .config/dotnet-tools.json
. Normally I would do it this way as it provides a easy way of managing what version of NuGetForUnity.Cli
is used in a clear way so you can update the version with dotnet tool update NuGetForUnity.Cli
. Also dependabot can handle updating tools defined in .config/dotnet-tools.json
see: dependabot/dependabot-core#7028.
Alternative you can do dotnet tool install --global NuGetForUnity.Cli
inside the action to always use the latest version, or specify the version by adding the --version
argument. But as I said I don't prefer it as you need to update the workflow to update the tool. Not specifying the version is also not recommended as you don't see when something changes / you can't roll back if something is failing.