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] Null check operator used on a null value #126

Closed
VeArnold opened this issue May 6, 2022 · 12 comments
Closed

[BUG] Null check operator used on a null value #126

VeArnold opened this issue May 6, 2022 · 12 comments
Assignees
Labels
bug Something isn't working

Comments

@VeArnold
Copy link
Contributor

VeArnold commented May 6, 2022

ℹ️ Info

Version: msix-3.6.0

💬 Description

Can not successfully build an unsigned package with version 3.6.0 of the tool.

a) I want to run the flutter build windows step separately, thus I added the --build-windows false flag
b) The CI/CD pipeline gets stuck at the prompt to install the certificate, so I added the --install-certificate flag
c) As I just want an unsigned package, I added the --sign-msix flag

However, this results in the following traceback:

PS C:\Users\builder\clone> flutter.BAT pub run msix:create --build-windows false --sign-msix false --install-certificate false                   
building msix files...                 -Unhandled exception:                                                                                     
Null check operator used on a null value                                                                                                         
#0      AppxManifest.generateAppxManifest (package:msix/src/appx_manifest.dart:39:45)                                                            
#1      Msix._buildMsixFiles (package:msix/msix.dart:118:26)                                                                                     
<asynchronous suspension>                                                                                                                        
#2      Msix._createMsix (package:msix/msix.dart:100:5)                                                                                          
<asynchronous suspension>                                                                                                                        
#3      Msix.create (package:msix/msix.dart:58:5)                                                                                                
<asynchronous suspension>                                                                                                                        
#4      main (file:///C:/Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/msix-3.6.0/bin/create.dart:4:3)   

Note that the same happens with my old project (which used to work), and also a totally clean new Windows Flutter project. In addition, also happens if I just use:
flutter.BAT pub run msix:create --build-windows false --sign-msix false

📜 Pubspec.yaml

Attached is the very basic Pubspec file.

name: ios_pingviin                                                                                                                               
description: Test project                                                                                                         
                                                            
publish_to: "none"                                                                     
version: 1.0.0+1                                                                                                                                 
                                                                                                                                                 
environment:                                                                                                                                     
  sdk: ">=2.12.0 <3.0.0"                                                                                                                         
                                                                                                                                                 
dependencies:                                                                                                                                    
  flutter:                                                                                                                                       
    sdk: flutter                                                                                                                                 
                                                                                                                                                                                                                              
  cupertino_icons: ^1.0.2                                                                                                                        
  sklite: ^0.0.1                                                                                                                                 
  msix: ^3.6.0                                                                                                                                   
                                                                                                                                                 
dev_dependencies:                                                                                                                                
  dart_code_metrics: ^4.1.0                                                                                                                      
  flutter_test:                                                                                                                                  
    sdk: flutter                                                                                                                                 
                                                                                                                                                                                                                                         
flutter:                                                                                                                                                                                                                                                 
  uses-material-design: true   
YehudaKremer added a commit that referenced this issue May 6, 2022
@YehudaKremer YehudaKremer added the bug Something isn't working label May 6, 2022
@YehudaKremer YehudaKremer self-assigned this May 6, 2022
@YehudaKremer
Copy link
Owner

YehudaKremer commented May 6, 2022

Hello @VeArnold

Thanks for this bug report.

All your args look good and valid.
I see a bug that we must have publisher value.

Details:
from version 2.5.4 we automatically get the publisher from the certificate,
and if you use --sign-msix false we don't have from where to get it, and we must add it manually.

So I published a new version (3.6.1), with validation on that,
also updated the documentation, and added a new example "Without signing".

Please update if it solves the problem.

@VeArnold
Copy link
Contributor Author

VeArnold commented May 6, 2022

Hi @YehudaKremer!

Thanks for the fast response. It fixed it to the degree that there's no weird error now, however, I am a bit confused about why the publisher field is required?

In the 2.5.4 changelog it says:

  • "publisher" configuration field is needed only for publish to windows store

What if I just want to create a "non-configured" MSIX package? I haven't used the package in a while, but back in November just running flutter run msix:create without any configuration seemed to do that. Perhaps I'm wrong.

@YehudaKremer
Copy link
Owner

YehudaKremer commented May 6, 2022

You can create msix without any configuration and args. (try it, run flutter run msix:create with out any args/flags)

But, You need to set the publisher value when you create unsigned msix
by using --store true, or --sign-msix false that added recently in version 3.1.4

@VeArnold
Copy link
Contributor Author

VeArnold commented May 6, 2022

@YehudaKremer

Thanks again for the quick response, though this new Y/n prompt seems to cause some issues. I was previously able to run it without any prompts, or errors. Now regardless of whether I choose Y or N, it errors.

With choosing Y:

PS C:\Users\builder\clone> flutter.BAT pub run msix:create --build-windows false                                                                 
building msix files...                 0.5s                                                                                                      
packing msix files...                                                                                                                            
                                                                                                                                                 
? Do you want to install the certificate: "test_certificate.pfx" ? (y/N) Yes                                                                     
the certificate installed successfully                                                                                                           
                                                                                                                                                 
Unhandled exception:                                                                                                                             
SignTool Error: No certificates were found that met all the given criteria.                                                                      
                                                                                                                                                 
#0      SignTool.sign (package:msix/src/sign_tool.dart:155:9)                                                                                    
<asynchronous suspension>                                                                                                                        
#1      Msix._packMsixFiles (package:msix/msix.dart:133:7)                                                                                       
<asynchronous suspension>                                                                                                                        
#2      Msix._createMsix (package:msix/msix.dart:101:5)                                                                                          
<asynchronous suspension>                                                                                                                        
#3      Msix.create (package:msix/msix.dart:58:5)                                                                                                
<asynchronous suspension>                                                                                                                        
#4      main (file:///C:/Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/msix-3.6.1/bin/create.dart:4:3)                       
<asynchronous suspension>                                                                                                                        
pub finished with exit code 255 

With choosing N:

PS C:\Users\builder\clone> flutter.BAT pub run msix:create --build-windows false                                                                 
building msix files...                 0.5s                                                                                                      
packing msix files...                                                                                                                            
                                                                                                                                                 
? Do you want to install the certificate: "test_certificate.pfx" ? (y/N) No                                                                      
                                                                                                                                                 
Unhandled exception:                                                                                                                             
SignTool Error: No certificates were found that met all the given criteria.                                                                      
                                                                                                                                                 
#0      SignTool.sign (package:msix/src/sign_tool.dart:155:9)                                                                                    
<asynchronous suspension>                                                                                                                        
#1      Msix._packMsixFiles (package:msix/msix.dart:133:7)                                                                                       
<asynchronous suspension>                                                                                                                        
#2      Msix._createMsix (package:msix/msix.dart:101:5)                                                                                          
<asynchronous suspension>                                                                                                                        
#3      Msix.create (package:msix/msix.dart:58:5)                                                                                                
<asynchronous suspension>                                                                                                                        
#4      main (file:///C:/Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/msix-3.6.1/bin/create.dart:4:3)                       
<asynchronous suspension>                                                                                                                        
pub finished with exit code 255 

Thus I don't see how there is an option to run it with out any args/flags or configuration.

@YehudaKremer
Copy link
Owner

Do you run this with CI/CD automation? or normal usage?

@VeArnold
Copy link
Contributor Author

VeArnold commented May 6, 2022

@YehudaKremer Well something in-between, I ran it in a CI/CD environment, but SSH'ed into it. (regardless it used to work fine with CI/CD)

@YehudaKremer
Copy link
Owner

YehudaKremer commented May 6, 2022

The new versions of this package have a default configuration for normal use.
for CI/CD you must use the --install-certificate false, that is why it used to work without it.

By default, the msix is signing with the test-certificate,
you can set the store flag (see documentation) to create unsign package,
or you can use your own certificate by setting the certificate details (path, password).

the --sign-msix false option is for rare use cases when you for some reason don't want to use the singing step of this package
and instead, you want to do it yourself (using directly the sign tool cli or some other tool).

All of those options are fully documented on the main documentation page.

@VeArnold
Copy link
Contributor Author

VeArnold commented May 6, 2022

@YehudaKremer Thanks again for the answer.

However, adding the --install-certificate false flag doesn't make any difference in comparison to just SSH'ing and opting for no. The result is obviously the same.

PS C:\Users\builder\clone> flutter.BAT pub run msix:create --build-windows false --install-certificate false   
building msix files...                 0.5s                                                                    
packing msix files...                                                                                          
                                                                                                               
Unhandled exception:                                                                                           
SignTool Error: No certificates were found that met all the given criteria.                                    
                                                                                                               
#0      SignTool.sign (package:msix/src/sign_tool.dart:155:9)                                                  
<asynchronous suspension>                                                                                      
#1      Msix._packMsixFiles (package:msix/msix.dart:133:7)                                                     
<asynchronous suspension>                                                                                      
#2      Msix._createMsix (package:msix/msix.dart:101:5)                                                        
<asynchronous suspension>                                                                                      
#3      Msix.create (package:msix/msix.dart:58:5)                                                              
<asynchronous suspension>                                                                                      
#4      main (file:///C:/Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/msix-3.6.1/bin/creat
e.dart:4:3)                                                                                                    
<asynchronous suspension>                                                                                      
pub finished with exit code 255

Thus I don't really understand what you mean. The --store flag also requires you to configure various other fields. What I am getting at is that the option to package without configuring anything seemingly has disappeared.

In that sense, as the final clarification, previously msix:create could be run with 0 configuration.

Now it seems the minimum way to get it to work to any degree at all, is to have publisher configured.

@VeArnold
Copy link
Contributor Author

VeArnold commented May 6, 2022

In addition, it would be nice if this change referenced in 3.6.1 could also account for the --publisher flag in the command. Currently, it looks like it requires the configuration to be present in pubspec.yaml.

@YehudaKremer
Copy link
Owner

Now it seems the minimum way to get it to work to any degree at all, is to have publisher configured.

On normal usage its works with 0 configurations:
image

on CI/CD I need to check why msix:create --build-windows false --install-certificate false give back "SignTool Error: No certificates were found that met all the given criteria." while singing with the test certificate.

@VeArnold
Copy link
Contributor Author

VeArnold commented May 6, 2022

@YehudaKremer Hi thanks, I think I managed to get it to work, the issue seems to appear if you've already tried to package once and then go for another spin. In a fresh env, it's OK.

Thanks!

@YehudaKremer
Copy link
Owner

I'm very happy to hear that!

But anyway, if this or another problem appears again, please let me know, I will spawn some ci/cd automation and check it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants