Closed abdusco closed 6 months ago
I think that you can use:
dotnet tool install --global --add-source <path-to-your-nuget-package> <tool-name>
I think that you can use:
dotnet tool install --global --add-source <path-to-your-nuget-package> <tool-name>
Just a quick note because I did the mistake, <path-to-your-nuget-package>
is the path of the folder, not the nupkg file. File name is loaded from <tool-name>
Just tried and found that <path-to-your-nuget-package>
should be the directory containing .nupkg file, not .nupkg file name itself. Hope it be useful for later users.
To add to what others have said: Unfortunately this can't just specify a path to a .nupkg file, you HAVE to provide the path to a directory in the first argument, meaning <path-to-your-nuget-package>
MUST be a directory, and then a name, which MUST repeat the nupkg name (without version, so for microsoft.botsay.1.0.0.nupkg
name is microsoft.botsay
).
So using their tutorial, if you follow the steps to make the simple little project and finally package the project to produce a .nupkg file (microsoft.botsay.1.0.0.nupkg
)... you can then move that nupkg file anywhere, including on another computer. Let's say you had that file living at: "C:\Code\Tools\Botsay\microsoft.botsay.1.0.0.nupkg": to install this as a global tool:
dotnet tool install -g --add-source C:\Code\Tools\Botsay microsoft.botsay
(of course you could have already been in a local folder, so if you were in Tools: `--add-source .\Botsay microsoft.botsay``
YES: It would be terrific if they could update this to install simply with the file path to a .nupkg! That said, it's awesome the main request is already available.
In order for me to get this to work inside a Docker image, had to reference the version number of the nuget package. In this example the structure was as follows:
-Dockerfile --tools ---dotnet-trace.3.1.141901.nupkg
To install from the root folder/docker context (after copying it into the context):
dotnet tool install --global --add-source ./tools dotnet-trace --version 3.1.141901
@abdusco take a look at this script we are using for our in-house tool:
https://github.com/morganstanley/dotnet-please/blob/main/build-and-install.ps1
NuGetToolsPath
is an optional environment variable in case you have restrictions on where executables can be installed.
When I specify a local nuget file to --add-source
, the error "NU1301: The local source '--add-source
option.
Adding --ignore-failed-sources
helped in my case:
dotnet tool update -g MyTool --add-source C:\Package --version 1.6.1-local1 --ignore-failed-sources
Close as alternative provided
I think that you can use:
dotnet tool install --global --add-source <path-to-your-nuget-package> <tool-name>
Preferably the installation should be done using a nuget.config that prevents the usage of all other sources such as nuget.org. So that the tool is installed from the local file only and there is no risk of installing a like-named malicious package, even if the name has not been reserved.
I set up a build system that creates and publishes both the nupkg and an installer script that creates and uses a temporary nuget.config file. But it would sure be nicer if dotnet tool install
itself had an option for this, e.g. --clear-sources
, if not direct support for a nupkg file argument.
Is there are way to install dotnet tools from nupkg files created by
dotnet pack <project>
?I want to quickly install and test my CLI tool but
dotnet tool install
requires installation from a nuget source.I can create a local nuget source with
nuget add source d:\path\to\nuget\files
but a way to directly install nupkg files would be great