Installer of type nullsoft does not seem to support by default another install dir.
I tried to install a program, nullsoft type, in another location using --location argument of winget.
I know it is supported by the installer but it does not work by default even it is seems it should from the source code
https://github.com/microsoft/winget-cli/blob/2667eadb1f61f6c9c80a5ff2e3f500c3e3ed712e/src/AppInstallerRepositoryCore/Manifest/ManifestInstaller.cpp#L127-L133
Try in powershell
winget install -l $env:USERPROFILE\Desktop\RStudio RStudio
If you clone the repository winget-pkg and modify the manifest to add a switches, it will work
cd .\manifests\RStudio\RStudio\
Add-Content .\1.2.5042.yaml " Switches:`n InstallLocation: /D=<INSTALLPATH>"
winget install -l $env:USERPROFILE\Desktop\RStudio -m .\1.2.5042.yml
This will install correctly in the specified location.
As winget seems to define by default the correct switch for nullsoft type, I would expect the installation is done in the specified location, and not have to provide the switch in manifest
Installing in the default location even if the --location is passed, unless the manifest precise the InstallLocation
[winget --info]
Windows Package Manager v0.1.41331 Aper莽u
Copyright (c) Microsoft Corporation. All rights reserved.
Windows: Windows.Desktop v10.0.18363.836
Package: Microsoft.DesktopAppInstaller v1.0.41331.0
Links:
Privacy Statement: https://aka.ms/winget-privacy
License agreement: https://aka.ms/winget-license
3rd Party Notices: https://aka.ms/winget-3rdPartyNotice
Homepage: https://aka.ms/winget
The problem is that by default it puts quotes around the path:
{InstallerSwitchType::InstallLocation, string_t("/D=\"" + std::string(ARG_TOKEN_INSTALLPATH) + "\"")}
NSIS documentation (3.2.1) says that no quotes must be used, even if the path contains spaces. It also requires that the installation path is the very last command-line argument and that the path must be absolute. So the proper fix seems to be:
Most helpful comment
The problem is that by default it puts quotes around the path:
NSIS documentation (3.2.1) says that no quotes must be used, even if the path contains spaces. It also requires that the installation path is the very last command-line argument and that the path must be absolute. So the proper fix seems to be: