jberezanski / ChocolateyPackages

Chocolatey packages maintained by me
MIT License
83 stars 51 forks source link

chocolatey-visualstudio.extension.1.10.2: Issue parsing some parameters. #142

Closed nicdompierre closed 5 months ago

nicdompierre commented 1 year ago

The visual studio installer have a special arguments with space within their neme:

--path cache="C:\VS\cache" --path shared="C:\VS\shared"

When passing theses arguments to chocolatey the Parse-Parameters in Parse-Parameters.ps1 in the extension crash as key and values are splitted by their space between them:

Exception lors de l'appel de « Add » avec « 2 » argument(s) : « L'élément a déjà été ajouté. Clé du dictionnaire : 'path' Clé ajoutée : 'path' »

I fixed it on my end this way, but it would be nice to get it fixed officially:

    If ($kvp.StartsWith("path ", "CurrentCultureIgnoreCase")) {
        $key = $kvp
        $value = ''
    }
    else {
        if ($delimiterIndex -lt $kvp.Length)
        {
            $value = $kvp.Substring($delimiterIndex + 1).Trim()
        }
        else
        {
            $value = ''
        }
    }

https://learn.microsoft.com/en-us/visualstudio/install/command-line-parameter-examples?view=vs-2022

jberezanski commented 1 year ago

Yes, those path arguments are troublesome; the package parameters parser was implemented long before Microsoft added them. The fix seems reasonable, I'll incorporate it (but no promises as to when).

jberezanski commented 1 year ago

Or maybe it will be simpler to just add "path" to the list of allowed multivalue parameters.

jberezanski commented 1 year ago

Another wrinkle: --path install=<path> is an alias for –-installPath <path>, so it would need to be recognized as such.

nicdompierre commented 1 year ago

Another wrinkle: --path install=<path> is an alias for –-installPath <path>, so it would need to be recognized as such.

Yeah, i hoped for an alias like --cachePath and --sharedPath, but they don't exist nor don't works at all.

jberezanski commented 1 year ago

Implemented in extension 1.11.0, currently in preview. Example:

cup -y chocolatey-visualstudio.extension --version 1.11.0-preview7
cup -y visualstudio2022buildtools --params "--locale en-US --path install=C:\VS 2022 BT --path shared=C:\VS 2022 Shared --path cache=C:\VS 2022 Cache --includeRecommended --includeOptional"

--path install=... is synonymous with --installPath ... (in fact, the extension internally converts the former to the latter).