Fix detection script to handle spinner lines and trailing count summaries in winget output#252
Fix detection script to handle spinner lines and trailing count summaries in winget output#252hafometh88 wants to merge 2 commits into
Conversation
… count summaries
Anchor header and data row extraction on the separator line ('^-{10,}')
instead of assuming the first alpha line is the header and the last line
is the data row.
Recent winget versions (1.7+) prepend progress spinner lines to stdout,
and some versions append a "N package(s)" count summary. Both caused
the parser to pick the wrong rows, resulting in exit 10 even when the
package was installed.
Also guard Substring() against out-of-bounds access when the data row
is shorter than the last header column position (e.g. when Available
and Source fields are blank and trailing whitespace is trimmed).
|
@svrooij Hello, is this project still being maintained? |
|
Yes it is, but my notifications where off for some reason |
There was a problem hiding this comment.
Pull request overview
This PR fixes the WinGet-based Intune detection script parsing so it correctly identifies installed apps across newer winget versions that emit progress/spinner lines before the table and may append a trailing N package(s) summary line after it.
Changes:
- Anchor table parsing on the dashed separator line (
^-{10,}) rather than assuming the first alpha line is the header and the last line is the data row. - Prevent
Substring()from throwing when data rows are shorter than expected (e.g., trailing columns are blank and whitespace is trimmed).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@hafometh88 I would like to run codeql first on the commits, but github is messing with me, would you be able to do this: git commit --allow-empty -m "trigger CI" && git push
which should trigger the workflow engine |
|
@svrooij done |
|
@svrooij the Build and Test C# failure isn't from this PR. It's The workflow pins 8.x | 9.x with no global.json, and the ubuntu-24.04 runner now has the .NET 10 SDK, whose formatter enforces that rule. Fails under 10.0.301, passes under 9.0.315. main would fail too if re-run. I can push the formatting pass or do you want to do it yourself later on main? |
|
No this is not your fault, I'll fix it. |

Fixes the auto-generated detection scripts that use
winget listto checkwhether an app installed by Intune is present. Apps were consistently
reported as not installed even when they were.
Recent winget versions (1.7+) write progress spinner lines to stdout before
the package table, and some versions append a
N package(s)count lineafter it. The parser assumed the first alpha line was the header and the
last line was the data row. Both assumptions break with the new output
format:
The header and data row are now anchored on the separator line (
^-{10,})which is stable across all winget versions and unaffected by anything
prepended or appended around the table.
Also fixed a latent
ArgumentOutOfRangeExceptioninSubstring()thatwould crash the script when a data row is shorter than the last header
column position (e.g. when the Available and Source fields are blank and
winget trims trailing whitespace).