Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Cert: can not found driver? #181

Closed
lucasjinreal opened this issue Feb 28, 2023 · 5 comments · Fixed by #200
Closed

[BUG] Cert: can not found driver? #181

lucasjinreal opened this issue Feb 28, 2023 · 5 comments · Fixed by #200
Labels
fixed bug fixed

Comments

@lucasjinreal
Copy link

packing msix files...

Unhandled exception:
dir : 找不到驱动器。名为“Cert”的驱动器不存在。

it says can not found dirver, I didn't know any about dirver? I have installed my own pfx file on my PC

@YehudaKremer
Copy link
Owner

@caiohamamura
Copy link
Contributor

caiohamamura commented May 25, 2023

I get the same problem, it is not driver issue, it is complaining about the drive when trying to locate the certificates under Cert:\

Here goes the verbose log:

[     0.012s] parsing cli arguments
[     0.084s] validating config values
[     0.088s] running "flutter build windows"...
[     7.902s] building msix files...
[     7.904s] validating build files
[     7.915s] cleaning temporary files
[     7.925s] create app icons
[     7.927s] generating icons
[    17.135s] copying VC libraries
[    17.165s] getting certificate publisher
[    17.166s] getting certificate "Subject" by file certificate
[    17.447s] generate appx manifest
[    17.453s] generate package resource indexing files
[    17.557s] packing msix files...
[    17.558s] packing
[    18.813s] cleaning temporary files
[    19.124s]
Unhandled exception:
dir : NÆo ‚ poss¡vel localizar a unidade. NÆo existe uma unidade com o nome 'Cert'.
No linha:1 caractere:1
+ dir Cert:\CurrentUser\Root | Where-Object { $_.Subject -eq  'CN=Msix  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Cert:String) [Get-ChildItem], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand


#0      ProcessResultExtensions.exitOnError (package:msix/src/method_extensions.dart:61:7)
#1      SignTool.installCertificate (package:msix/src/sign_tool.dart:156:13)
<asynchronous suspension>
#2      Msix._packMsixFiles (package:msix/msix.dart:134:9)
<asynchronous suspension>
#3      Msix._createMsix (package:msix/msix.dart:99:5)
<asynchronous suspension>
#4      Msix.create (package:msix/msix.dart:57:5)
<asynchronous suspension>
#5      main (file:///C:/Users/caioh/AppData/Local/Pub/Cache/hosted/pub.dev/msix-3.13.2/bin/create.dart:4:3)
<asynchronous suspension>

For what I understand the problem is with dir Cert:CurrentUser\Root, this is only a valid command in powershell, if you run that in a cmd you will get the same error. That's why powershell tells you to avoid aliases, maybe if you use Get-ChildItem instead it will work?

@caiohamamura
Copy link
Contributor

caiohamamura commented May 25, 2023

I think I get it, it is because I've installed the Powershell Core v7. So that may have messed up with the original PSModulePath that the regular Powershell also uses. If I change powershell.exe to pwsh.exe and add a -Command argument before the actual command in:

await Process.run('powershell.exe', [

Everything works! I don't know how to provide a solution to that issue tough, since it is not everybody who has the pwsh.exe installed.

@caiohamamura
Copy link
Contributor

Okay, now I kind of get it. The only way to reproduce this problem is to run the command from inside the pwsh.exe itself, then it will mix up what Modules to load because the pwsh.exe will inject its modules directories inside $env:PSModulePath, so when we call powershell.exe from inside, it will try to load the Powershell Core modules and the problem will arise.

A way to hack around it would be to reread the $env:PSModulePath from the registry before running the dir Cert:\.

We could replace the:

"dir Cert:\\CurrentUser\\Root | Where-Object { \$_.Subject -eq '${_config.publisher}'}"

With:

      "\$env:PSModulePath = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine');dir Cert:\\CurrentUser\\Root | Where-Object { \$_.Subject -eq  '${_config.publisher}'}"

caiohamamura added a commit to caiohamamura/msix that referenced this issue May 25, 2023
YehudaKremer added a commit that referenced this issue May 31, 2023
@YehudaKremer
Copy link
Owner

Hello

@caiohamamura thanks you for research and the PR fix 👍
i publish new version 3.13.3 with the fix.

@YehudaKremer YehudaKremer added the fixed bug fixed label May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed bug fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants