-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inform user if a module requires elevation (#3758)
Fix #3747 Add a new HRESULT for failed importing module because the module requires to run as admin. Also fix places where WINGET_CONFIG_ERROR_UNIT_SETTING_CONFIG_ROOT was missing. We can't have automated tests because we don't currently have a way to run winget as non admin in our tests. I created a UT with a simple test that is skipped in ADO. I also removed printing details for WINGET_CONFIG_ERROR_UNIT_IMPORT_MODULE because I noticed that "error code could not be found" message is coming the IConfigurationUnitResultInformation description. Apply :: VSComponents Loading the module for the configuration unit failed. The text associated with this error code could not be found. Some of the configuration was not applied successfully. In the configuration module, the IConfigurationUnitResultInformation description is the actual error message that we set in ImportModuleException. My guess is that cppwinrt use some method to get message of well-known errors and set that, but I didn't want to go that deep, so removing it because we are literally printing a line before the text associated with that error code.
- Loading branch information
1 parent
a10f1ab
commit e991523
Showing
18 changed files
with
178 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ion.UnitTests/TestCollateral/PowerShellModules/xAdminTestResource/xAdminTestResource.psd1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# | ||
# Module manifest for module 'xAdminTestResource' | ||
# | ||
# Generated by: Luffytaro | ||
# | ||
# Generated on: 10/11/2023 | ||
# | ||
|
||
@{ | ||
|
||
RootModule = 'xAdminTestResource.psm1' | ||
ModuleVersion = '0.0.0.1' | ||
GUID = 'a0be43e8-ac22-4244-8efc-7263dfa58b8c' | ||
CompatiblePSEditions = 'Core' | ||
Author = 'Luffytaro' | ||
CompanyName = 'Microsoft Corporation' | ||
Copyright = '(c) Microsoft Corporation. All rights reserved.' | ||
Description = 'PowerShell module with DSC resources for unit tests that requires admin' | ||
PowerShellVersion = '7.2' | ||
FunctionsToExport = @() | ||
CmdletsToExport = @() | ||
DscResourcesToExport = @( | ||
'AdminResource' | ||
) | ||
HelpInfoURI = 'https://www.contoso.com/help' | ||
|
||
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. | ||
PrivateData = @{ | ||
|
||
PSData = @{ | ||
ProjectUri = 'https://github.com/microsoft/winget-cli' | ||
IconUri = 'https://www.contoso.com/icons/icon.png' | ||
} | ||
|
||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...ion.UnitTests/TestCollateral/PowerShellModules/xAdminTestResource/xAdminTestResource.psm1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Simple module that requires admin. | ||
#Requires -RunAsAdministrator | ||
enum Ensure | ||
{ | ||
Absent | ||
Present | ||
} | ||
|
||
[DscResource()] | ||
class AdminResource | ||
{ | ||
[DscProperty(Key)] | ||
[string] $key | ||
|
||
[AdminResource] Get() | ||
{ | ||
return $this | ||
} | ||
|
||
[bool] Test() | ||
{ | ||
return $false | ||
} | ||
|
||
[void] Set() | ||
{ | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/PowerShell/Microsoft.WinGet.Configuration.Engine/Resources/Resources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters