@@ -67,12 +67,14 @@ public static Command Create(Option<string?> outputOption)
6767 var stateVerify = new Option < string ? > ( "--state" , "Publisher working directory" ) ;
6868 var buildVerify = new Option < string ? > ( "--build" , "Build snapshot ID" ) ;
6969 var destinationVerify = new Option < string ? > ( "--destination" , "Published static source directory" ) ;
70- var signToolVerify = new Option < string ? > ( "--signtool" , "Path to signtool.exe" ) ;
70+ var psignToolVerify = PsignToolOption ( ) ;
71+ var trustedCaVerify = TrustedCaOption ( ) ;
7172 var verify = new Command ( "verify" , "Verify a build snapshot or published directory" ) ;
7273 verify . AddOption ( stateVerify ) ;
7374 verify . AddOption ( buildVerify ) ;
7475 verify . AddOption ( destinationVerify ) ;
75- verify . AddOption ( signToolVerify ) ;
76+ verify . AddOption ( psignToolVerify ) ;
77+ verify . AddOption ( trustedCaVerify ) ;
7678 verify . SetHandler ( context => Run ( context , outputOption , ( ) =>
7779 {
7880 var state = context . ParseResult . GetValueForOption ( stateVerify ) ;
@@ -81,8 +83,12 @@ public static Command Create(Option<string?> outputOption)
8183 throw new PublisherException ( "Provide exactly one of --state or --destination." ) ;
8284 if ( destination is not null && context . ParseResult . GetValueForOption ( buildVerify ) is not null )
8385 throw new PublisherException ( "--build cannot be combined with --destination." ) ;
86+ var psignTool = context . ParseResult . GetValueForOption ( psignToolVerify ) ;
87+ var trustedCa = context . ParseResult . GetValueForOption ( trustedCaVerify ) ?? [ ] ;
88+ if ( destination is null && ( psignTool is not null || trustedCa . Length > 0 ) )
89+ throw new PublisherException ( "--psign-tool and --trusted-ca require --destination." ) ;
8490 var result = destination is not null
85- ? PublisherPackaging . VerifyDestination ( destination , context . ParseResult . GetValueForOption ( signToolVerify ) )
91+ ? PublisherPackaging . VerifyDestination ( destination , psignTool , trustedCa )
8692 : new PublisherWorkspace ( state ! ) . Verify ( context . ParseResult . GetValueForOption ( buildVerify ) ) ;
8793 return ( Object (
8894 ( "valid" , JsonValue . Create ( result . Valid ) ) ,
@@ -92,22 +98,17 @@ public static Command Create(Option<string?> outputOption)
9298 $ "Verified { result . Subject } ; artifacts: { result . ArtifactCount } .") ;
9399 } ) ) ;
94100
95- var makeAppxDoctor = new Option < string ? > ( "--makeappx" , "Path to makeappx.exe" ) ;
96- var signToolDoctor = new Option < string ? > ( "--signtool" , "Path to signtool.exe" ) ;
97- var doctor = new Command ( "doctor" , "Check local publisher capabilities and packaging tools" ) ;
98- doctor . AddOption ( makeAppxDoctor ) ;
99- doctor . AddOption ( signToolDoctor ) ;
101+ var psignToolDoctor = PsignToolOption ( ) ;
102+ var doctor = new Command ( "doctor" , "Check local publisher capabilities and signing tools" ) ;
103+ doctor . AddOption ( psignToolDoctor ) ;
100104 doctor . SetHandler ( context => Run ( context , outputOption , ( ) =>
101105 {
102- var result = PublisherPackaging . Doctor (
103- context . ParseResult . GetValueForOption ( makeAppxDoctor ) ,
104- context . ParseResult . GetValueForOption ( signToolDoctor ) ) ;
106+ var result = PublisherPackaging . Doctor ( context . ParseResult . GetValueForOption ( psignToolDoctor ) ) ;
105107 return ( Object (
106108 ( "operatingSystem" , JsonValue . Create ( result . OperatingSystem ) ) ,
107- ( "makeAppxPath" , JsonValue . Create ( result . MakeAppxPath ) ) ,
108- ( "signToolPath" , JsonValue . Create ( result . SignToolPath ) ) ,
109+ ( "psignToolPath" , JsonValue . Create ( result . PsignToolPath ) ) ,
109110 ( "nativeMsZipAvailable" , JsonValue . Create ( result . NativeMsZipAvailable ) ) ) ,
110- $ "MSZIP: { ( result . NativeMsZipAvailable ? "available" : "unavailable" ) } ; makeappx : { result . MakeAppxPath ?? "not found" } ; signtool : { result . SignToolPath ?? "not found" } .") ;
111+ $ "MSZIP: { ( result . NativeMsZipAvailable ? "available" : "unavailable" ) } ; psign-tool : { result . PsignToolPath ?? "not found" } ; signed publishing available : { ( result . SignedPublishAvailable ? "yes" : "no" ) } .") ;
111112 } ) ) ;
112113
113114 var statePublish = new Option < string > ( "--state" , "Publisher working directory" ) { IsRequired = true } ;
@@ -118,15 +119,15 @@ public static Command Create(Option<string?> outputOption)
118119 var pfxPublish = new Option < string ? > ( "--pfx" , "PFX file used to sign the source MSIX" ) ;
119120 var passwordEnvPublish = new Option < string ? > ( "--password-env" , "Environment variable containing the PFX password" ) ;
120121 var unsignedPublish = new Option < bool > ( "--unsigned-development" , "Allow explicitly unsigned development publishing" ) ;
121- var makeAppxPublish = new Option < string ? > ( "--makeappx" , "Path to makeappx.exe" ) ;
122- var signToolPublish = new Option < string ? > ( "--signtool" , "Path to signtool.exe" ) ;
122+ var psignToolPublish = PsignToolOption ( ) ;
123+ var trustedCaPublish = TrustedCaOption ( ) ;
123124 var timestampPublish = new Option < string ? > ( "--timestamp-url" , "HTTPS RFC 3161 timestamp service URL" ) ;
124125 var buildPublish = new Option < string ? > ( "--build" , "Build snapshot ID (defaults to latest)" ) ;
125126 var publish = new Command ( "publish" , "Package and publish a source2.msix and immutable artifacts" ) ;
126127 foreach ( var option in new Option [ ]
127128 {
128129 statePublish , destinationPublish , namePublish , publisherPublish , versionPublish ,
129- pfxPublish , passwordEnvPublish , unsignedPublish , makeAppxPublish , signToolPublish , buildPublish , timestampPublish ,
130+ pfxPublish , passwordEnvPublish , unsignedPublish , psignToolPublish , trustedCaPublish , buildPublish , timestampPublish ,
130131 } )
131132 publish . AddOption ( option ) ;
132133 publish . SetHandler ( context => Run ( context , outputOption , ( ) =>
@@ -140,10 +141,10 @@ public static Command Create(Option<string?> outputOption)
140141 context . ParseResult . GetValueForOption ( pfxPublish ) ,
141142 context . ParseResult . GetValueForOption ( passwordEnvPublish ) ,
142143 context . ParseResult . GetValueForOption ( unsignedPublish ) ,
143- context . ParseResult . GetValueForOption ( makeAppxPublish ) ,
144- context . ParseResult . GetValueForOption ( signToolPublish ) ,
144+ context . ParseResult . GetValueForOption ( psignToolPublish ) ,
145145 context . ParseResult . GetValueForOption ( buildPublish ) ,
146- context . ParseResult . GetValueForOption ( timestampPublish ) ) ) ;
146+ context . ParseResult . GetValueForOption ( timestampPublish ) ,
147+ context . ParseResult . GetValueForOption ( trustedCaPublish ) ) ) ;
147148 return ( Object (
148149 ( "valid" , JsonValue . Create ( result . Valid ) ) ,
149150 ( "subject" , JsonValue . Create ( result . Subject ) ) ,
@@ -161,6 +162,16 @@ public static Command Create(Option<string?> outputOption)
161162 return root ;
162163 }
163164
165+ private static Option < string ? > PsignToolOption ( ) =>
166+ new ( "--psign-tool" , "Path to psign-tool (searched on PATH and in the .NET global tool directory when omitted)" ) ;
167+
168+ private static Option < string [ ] > TrustedCaOption ( ) =>
169+ new ( "--trusted-ca" , "Certificate trusted as a signature anchor instead of the platform default (repeatable)" )
170+ {
171+ ArgumentHelpName = "certificate" ,
172+ AllowMultipleArgumentsPerToken = false ,
173+ } ;
174+
164175 private static Option < string > InputOption ( )
165176 {
166177 var option = new Option < string > ( "--input" , "Root directory containing WinGet YAML manifests" ) { IsRequired = true } ;
0 commit comments