Skip to content

Fix versionless install/uninstall scripts to include full winget args#251

Merged
svrooij merged 3 commits into
svrooij:mainfrom
hafometh88:fix/versionless-missing-winget-args
Jun 16, 2026
Merged

Fix versionless install/uninstall scripts to include full winget args#251
svrooij merged 3 commits into
svrooij:mainfrom
hafometh88:fix/versionless-missing-winget-args

Conversation

@hafometh88

Copy link
Copy Markdown
Contributor

Fixes #240

When running New-WtWingetPackage -version latest -PackageScript, the generated scripts were missing most of the winget arguments:

# what you got
$(Get-WingetCmd) "install" "--id" "Microsoft.VisualStudioCode" "--exact"

# what you'd get with an explicit version
$(Get-WingetCmd) "install" "--id" "Microsoft.VisualStudioCode" "--version" "1.104.2" "--source" "winget" "--silent" "--accept-package-agreements" "--accept-source-agreements" "--scope" "user"

The versionless path had its own hardcoded command builders that never got the --source, --silent, --accept-* and --scope treatment. The non-versionless path was already using WingetHelper.GetInstallArgumentsForPackage which does all of that correctly so the fix is just making both paths use the same thing.

Removed GetWingetInstallCmd and GetWingetUninstallCmd from IntuneManagerConstants since nothing else used them.

Added tests for InstallerContext.User, System and Unknown to make sure the right flags (including --scope) end up in the generated scripts.

hafometh88 and others added 3 commits April 22, 2026 15:50
When using -version latest with -PackageScript, the generated scripts
were missing --source, --silent, --accept-package-agreements,
--accept-source-agreements and --scope. Replace the minimal hardcoded
command builders with WingetHelper.GetInstallArgumentsForPackage and
GetUninstallArgumentsForPackage, which already produce the correct
full argument list. Remove the now-unused GetWingetInstallCmd and
GetWingetUninstallCmd helpers from IntuneManagerConstants.

Fixes svrooij#240
Add a parameterised test covering InstallerContext User, System and
Unknown to assert that the generated install.ps1 and uninstall.ps1
for versionless packages contain --source, --silent,
--accept-package-agreements, --accept-source-agreements and the
correct --scope value (or none when context is Unknown).
@svrooij svrooij merged commit b745d51 into svrooij:main Jun 16, 2026
5 of 6 checks passed
@hafometh88 hafometh88 deleted the fix/versionless-missing-winget-args branch June 16, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: PowerShell when using "-version latest" the winget installer parameters seems not to be complete

2 participants