winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

Support additional arguments as well as overridden arguments

Open gmckeown opened this issue 5 years ago • 12 comments

Description of the new feature/enhancement

Some installers, for example WinSCP, pop up a dialog asking whether I wish to install for current user or all users (note: #149 might be relevant for this specific case).

WinSCP supports the /ALLUSERS and /CURRENTUSER options to cater for this; however, if I use --override it clears all options specified in the manifest and replaces them. So the following ends up performing an interactive install:

winget install --override "/ALLUSERS" winscp

So I locate the manifest, identify that it has the /VERYSILENT option and change my command to:

winget install --override "/VERYSILENT /ALLUSERS" winscp

This achieves what I want -- a completely silent install with my chosen option.

Proposed technical implementation details (optional)

A new switch that adds the listed arguments to the installer command-line rather than replaces them. This would supplement the --override option rather than replacing it.

Something along the lines of the following would then allow me to retain the manifest-specified default options, whilst still including my choices:

winget install --pass-args "/ALLUSERS" winscp

They key benefit here is that if the authors of the manifest add new default options, I don't have to manually modify my install command to match.

gmckeown avatar May 20 '20 11:05 gmckeown

I would like to see custom install arguments for each app when I do:

> winget install Microsoft.VisualStudio --help
> --python - Installs python
> --Node - Installs Node
> etc....

I would also like a guided installation where the installer UI shows up and I can personally select options and manually hit next, next, next, finish.

> winget install Microsoft.VisualStudio --guided

RehanSaeed avatar May 23 '20 07:05 RehanSaeed

I found an opportunity to specify additional attributes in the manifest and in the source code, but this is not fully implemented. Cannot be started with the described command. You cannot get data from manifest when getting information about a package (winget show) and when polling a command (example winget install TestApp -custom -?). https://github.com/microsoft/winget-cli/discussions/1067

iDolmatov avatar Jun 01 '21 23:06 iDolmatov

@RehanSaeed winget install <package> --interactive should do what you're looking for.

 winget install -?
Windows Package Manager v1.0.11451
Copyright (c) Microsoft Corporation. All rights reserved.

Installs the selected package, either found by searching a configured source or directly from a manifest. By default, the query must case-insensitively match the id, name, or moniker of the package. Other fields can be used by passing their appropriate option.

usage: winget install [[-q] <query>] [<options>]

The following arguments are available:
  -q,--query        The query used to search for a package

The following options are available:
  -m,--manifest     The path to the manifest of the package
  --id              Filter results by id
  --name            Filter results by name
  --moniker         Filter results by moniker
  -v,--version      Use the specified version; default is the latest version
  -s,--source       Find package using the specified source
  --scope           Select install scope (user or machine)
  -e,--exact        Find package using exact match
  -i,--interactive  Request interactive installation; user input may be needed
  -h,--silent       Request silent installation
  --locale          Locale to use (BCP47 format)
  -o,--log          Log location (if supported)
  --override        Override arguments to be passed on to the installer
  -l,--location     Location to install to (if supported)

More help can be found at: https://aka.ms/winget-command-install

denelon avatar Jun 02 '21 20:06 denelon

@RehanSaeed winget install <package> --interactive should do what you're looking for.

This is not what he is asking for. We need a hidden installation, but with the ability to specify parameters.

The existing parameters in the manifest must be saved so that the user does not rewrite them. The key I mentioned would be quite applicable when you specify additional parameters after this key. If some switches from the "Silent" / "SilentWithProgress" / "Interactive" lines are duplicated with those entered after "Custom", then the duplicated switches are not reused. Additionally, should be added a "--help-custom" command, which will show the valid parameters based on the data from the manifest. If there is no data in the manifest, look at the type of the installer and indicate the known switches for this type.

At the moment, none of the moderators and developers have been able to fully explain how the "Custom" switch works. The description of this key explicitly states that it is used for additional parameters. It is not logical if it is automatically added to the required parameters. Either this key is not fully implemented, or there is a bug with its work and lack of description.

iDolmatov avatar Jun 02 '21 21:06 iDolmatov

Examples (not real data). Use winget install <package> --interactive /custom /D=C:\MyProgram winget install <package> /custom /D=C:\MyProgram winget install <package> --scope USER /custom /Portable /D=F:\MyProgram

Help (not real data) winget install <package> --helpcustom Answer: /D /F /L=%Location%

iDolmatov avatar Jun 02 '21 21:06 iDolmatov

@iDolmatov "Custom" switches are passed to the installer regardless of whether it is executed with "Silent", "SilentWithProgress", or "Interactive". The "Custom" switches are optional, and not required. The only time "Silent" and "SilentWithProgress" are required is when you have an .exe installer (not Nullsoft, Inno, or another known "InstallerType") to support those installation modes in the client.

denelon avatar Jun 02 '21 23:06 denelon

https://github.com/microsoft/winget-pkgs/tree/master/manifests/a/AIMP/AIMP Custom: /RUN

What's wrong? Bug?

Try use: winget install AIMP /custom winget install AIMP -custom winget install AIMP --custom

Edit: Shortcut comment needless info.

iDolmatov avatar Jun 02 '21 23:06 iDolmatov

The "Custom" flags are passed to the installer in addition to the "Silent" or "SilentWithProgress" or "Interactive" depending on what install mode was selected.

For a "Silent" install, the installer would receive /RUN /AUTO /SILENT. For a "SilentWithProgress" install, the installer would receive /RUN /AUTO. For an "Interactive" install, the installer would receive /RUN.

denelon avatar Jun 03 '21 00:06 denelon

Thank you. Insufficient description of the parameter and its name misled me. Thought it meant another installation mode. It turns out that this is a kind of "ForcedSwitch".

Please indicate which is always used: https://github.com/microsoft/winget-pkgs/blob/master/Tools/YamlCreate.ps1

https://github.com/microsoft/winget-cli/blob/master/schemas/JSON/manifests/v1.0.0/manifest.installer.1.0.0.json Custom switches will be passed directly to the installer by winget in any installation mode.

iDolmatov avatar Jun 03 '21 00:06 iDolmatov

I'm working on another set of documents designed to explain all of the fields fully. I'm also writing more thorough guidance on authoring manifests. The current document is a stub so I can start doing some refactoring on other documents. More to come 😊

denelon avatar Jun 03 '21 01:06 denelon

@gmckeown we added support for "user" vs. "machine" install. Manifests can have both flavors. We still don't have an additive argument for passing arguments in addition rather than an override, so I'll keep this issue open.

denelon avatar Jun 25 '21 21:06 denelon

@denelon - See above linked PR

Trenly avatar Jan 13 '23 04:01 Trenly

All, @Trenly implemented "--custom".

If you pass "--custom" and arguments, they will be added to the existing arguments provided by WinGet and the manifest.

Note: if you use "--override", the "--custom" arguments are ignored.

denelon avatar Feb 21 '23 19:02 denelon