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

Implement PowerShell cmdlets

Open msftrubengu opened this issue 2 years ago • 3 comments

This PR implements two new PowerShelll cmdlets Assert-WinGetIntegrity and Repair-WinGet as well as the WinGetIntegrityResource DSC Resource.

Assert-WinGetIntegrity verifies the integrity of winget for the current user. If winget is not set up correctly, it will throw an exception with the type of failure if detected. It can detect:

  • Failed call into winget --version.
  • winget is not found because is not in the PATH environment variable.
  • winget is not found because the App execution alias is disabled.
  • Windows OS is not supported.
  • The AppInstaller package is not installed in the machine.
  • The AppInstaller package is not registered for the user.
  • The AppInstaller package is old and doesn't contain winget.

Assert-WinGetIntegrity -Version foo also verifies the installed version is the same as the expected. Assert-WinGetIntegrity -Latest also verifies the installed version is the latest release version. Assert-WinGetIntegrity -Latest -IncludePrerelease also verifies the installed version is the latest prerelease version.

Repair-WinGet does the same as Assert-WinGetIntegrity but attempts to fix winget depending on the failure. Returns 0 is succeeded.

Repair-WinGet repairs current winget installed and performs no updates. If winget is not installed or there's catastrophic failure then installs the latest released winget. Repair-WinGet -Version foo repairs winget and makes sure that the current installed version is the expected one. Repair-WinGet -Latest repairs winget and makes sure winget is the latest released version. Repair-WinGet -Latest -IncludePreRelease repairs winget and makes sure winget is the latest prereleased version.

It sadly can't repair if AppExecution alias is disabled because there's no programmatic way to do it (requires internal APIs).

It also doesn't install Microsoft.UI.Xaml.2.7 as a dependency because the current solution to download the nuget package, extract it and install the appx within is not the right approach we want to follow. We will follow up internally with the owners of the package to do something similar as the VCLibs packages.

There's still a lot of opportunity for Repair-WinGet to make it more robust.

The WinGetIntegrityResource DSC resource is just a simple wrapper around those two cmdlets. There's also a sample on how to use it.

For now, all versions need to be the tag name of the releases in GitHub.

Also, moved Get-WinGetVersion from Crescendo to a binary cmdlet.

Microsoft Reviewers: Open in CodeFlow

msftrubengu avatar Jan 11 '23 04:01 msftrubengu

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view or the :scroll:action log for details.

Unrecognized words (4)

PFM PSHOST remoting SCmdlet

Previously acknowledged words that are now absent PWSTR :arrow_right:
To accept :heavy_check_mark: these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the [email protected]:msftrubengu/winget-cli.git repository on the wingetintegrity branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.21/apply.pl' |
perl - 'https://github.com/microsoft/winget-cli/actions/runs/3889568597/attempts/1'
Available :books: dictionaries could cover words not in the :blue_book: dictionary

This includes both expected items (405) from .github/actions/spelling/expect.txt and unrecognized words (4)

Dictionary Entries Covers
cspell:cpp/src/cpp.txt 30216 26
cspell:win32/src/win32.txt 53509 18
cspell:python/src/python/python-lib.txt 3873 7
cspell:php/php.txt 2597 6
cspell:java/java.txt 7642 5
cspell:python/src/python/python.txt 453 3
cspell:python/src/common/extra.txt 741 3
cspell:django/django.txt 859 3
cspell:typescript/typescript.txt 1211 2
cspell:npm/npm.txt 288 2

Consider adding them using (in .github/workflows/spelling3.yml):

      with:
        extra_dictionaries:
          cspell:cpp/src/cpp.txt
          cspell:win32/src/win32.txt
          cspell:python/src/python/python-lib.txt
          cspell:php/php.txt
          cspell:java/java.txt
          cspell:python/src/python/python.txt
          cspell:python/src/common/extra.txt
          cspell:django/django.txt
          cspell:typescript/typescript.txt
          cspell:npm/npm.txt

To stop checking additional dictionaries, add:

      with:
        check_extra_dictionaries: ''
If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar Jan 11 '23 04:01 github-actions[bot]

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view or the :scroll:action log for details.

Unrecognized words (4)

PFM PSHOST remoting SCmdlet

Previously acknowledged words that are now absent PWSTR :arrow_right:
To accept :heavy_check_mark: these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the [email protected]:msftrubengu/winget-cli.git repository on the wingetintegrity branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.21/apply.pl' |
perl - 'https://github.com/microsoft/winget-cli/actions/runs/3896868071/attempts/1'
Available :books: dictionaries could cover words not in the :blue_book: dictionary

This includes both expected items (405) from .github/actions/spelling/expect.txt and unrecognized words (4)

Dictionary Entries Covers
cspell:cpp/src/cpp.txt 30216 26
cspell:win32/src/win32.txt 53509 18
cspell:python/src/python/python-lib.txt 3873 7
cspell:php/php.txt 2597 6
cspell:java/java.txt 7642 5
cspell:python/src/python/python.txt 453 3
cspell:python/src/common/extra.txt 741 3
cspell:django/django.txt 859 3
cspell:typescript/typescript.txt 1211 2
cspell:npm/npm.txt 288 2

Consider adding them using (in .github/workflows/spelling3.yml):

      with:
        extra_dictionaries:
          cspell:cpp/src/cpp.txt
          cspell:win32/src/win32.txt
          cspell:python/src/python/python-lib.txt
          cspell:php/php.txt
          cspell:java/java.txt
          cspell:python/src/python/python.txt
          cspell:python/src/common/extra.txt
          cspell:django/django.txt
          cspell:typescript/typescript.txt
          cspell:npm/npm.txt

To stop checking additional dictionaries, add:

      with:
        check_extra_dictionaries: ''
If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar Jan 11 '23 21:01 github-actions[bot]

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view or the :scroll:action log for details.

Unrecognized words (2)

demostrate prereleased

Previously acknowledged words that are now absent PWSTR :arrow_right:
To accept :heavy_check_mark: these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the [email protected]:msftrubengu/winget-cli.git repository on the wingetintegrity branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.21/apply.pl' |
perl - 'https://github.com/microsoft/winget-cli/actions/runs/3898861681/attempts/1'
Available :books: dictionaries could cover words not in the :blue_book: dictionary

This includes both expected items (408) from .github/actions/spelling/expect.txt and unrecognized words (2)

Dictionary Entries Covers
cspell:cpp/src/cpp.txt 30216 26
cspell:win32/src/win32.txt 53509 18
cspell:python/src/python/python-lib.txt 3873 7
cspell:php/php.txt 2597 6
cspell:java/java.txt 7642 5
cspell:python/src/python/python.txt 453 3
cspell:python/src/common/extra.txt 741 3
cspell:django/django.txt 859 3
cspell:typescript/typescript.txt 1211 2
cspell:npm/npm.txt 288 2

Consider adding them using (in .github/workflows/spelling3.yml):

      with:
        extra_dictionaries:
          cspell:cpp/src/cpp.txt
          cspell:win32/src/win32.txt
          cspell:python/src/python/python-lib.txt
          cspell:php/php.txt
          cspell:java/java.txt
          cspell:python/src/python/python.txt
          cspell:python/src/common/extra.txt
          cspell:django/django.txt
          cspell:typescript/typescript.txt
          cspell:npm/npm.txt

To stop checking additional dictionaries, add:

      with:
        check_extra_dictionaries: ''
If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar Jan 12 '23 03:01 github-actions[bot]

/azp run

msftrubengu avatar Mar 07 '23 18:03 msftrubengu

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Mar 07 '23 18:03 azure-pipelines[bot]