2

我正在尝试使用Microsoft桌面应用转换器(AKA Desktop Bridge),并且我们的发布者名称中包含逗号,空格和句点。如何在Powershell中指定复杂的发布者名称?

例如。 CN="Acme, Inc."

这不起作用:

DesktopAppConverter.exe -Installer .\Installer.msi -Destination AppxFolder -PackageName "AcmeApp" -Publisher "CN=Acme, Inc." -Version 1.0.0.0 -MakeAppx 

我已经想尽各种办法逃避像引号:

-Publisher "CN=\`"Acme`, Inc.\`"" 

结果:

A positional parameter cannot be found that accepts argument 'Inc.'.

此:

-Publisher 'CN="Acme, Inc."' 

结果:

Appx manifest validation failed because of an invalid input: 'Publisher' cannot be assigned a value 'CN=Acme, Inc.' Original Error: 'Exception calling "SetPackageIdentityPublisher" with "1" argument(s): "Validating AppxManifest.xml against schemas failed with error(s): Error found in XML (0): The 'Publisher' attribute is invalid - The value 'CN=Acme, Inc.' is invalid according to its datatype 'http://schemas.microsoft.com/appx/manifest/types:ST_Publisher_2010_v2' - The Pattern constraint failed.

此:

-Publisher 'CN="Acme\`, Inc."' 

结果:

Appx manifest validation failed because of an invalid input: 'Publisher' cannot be assigned a value 'CN=Acme`, Inc.' Original Error: 'Exception calling "SetPackageIdentityPublisher" with "1" argument(s): "Validating AppxManifest.xml against schemas failed with error(s):
Error found in XML (0): The 'Publisher' attribute is invalid - The value 'CN=Acme`, Inc.' is invalid according to its datatype 'http://schemas.microsoft.com/appx/manifest/types:ST_Publisher_2010_v2' - The Pattern constraint failed.

此:

-Publisher "CN=Acme, Inc." 

结果在:

Appx manifest validation failed because of an invalid input: 'Publisher' cannot be assigned a value 'CN=Acme, Inc.' Original Error: 'Exception calling "SetPackageIdentityPublisher" with "1" argument(s): "Validating AppxManifest.xml against schemas failed with error(s): Error found in XML (0): The 'Publisher' attribute is invalid - The value 'CN=Acme, Inc.' is invalid according to its datatype ' http://schemas.microsoft.com/appx/manifest/types:ST_Publisher_2010_v2 ' - The Pattern constraint failed.

此:

-Publisher "CN='Acme\, Inc.'" 

结果:

A positional parameter cannot be found that accepts argument 'System.Object[]'.

此:

-Publisher "CN=Acme\, Inc." 

结果:

Appx manifest validation failed because of an invalid input: 'Publisher' cannot be assigned a value 'CN=Acme\, Inc.' Original Error: 'Exception calling "SetPackageIdentityPublisher" with "1" argument(s): "Validating AppxManifest.xml against schemas failed with error(s): Error found in XML (0): The 'Publisher' attribute is invalid - The value 'CN=Acme\, Inc.' is invalid according to its datatype ' http://schemas.microsoft.com/appx/manifest/types:ST_Publisher_2010_v2 ' - The Pattern constraint failed.

这非常烦人,因为我们需要完全设置发布者名称,否则签名将无法正常工作,因为它与我们的代码签名证书中的发布者名称不匹配。

这样做的正确方法是什么?

回答

0

除了双引号之外,您还需要转义逗号。另外,将enire通用名称放在单引号中,而不是双引号,因此您不需要转义两次(对于PowerShell Active Directory)。

... -Publisher 'CN=\"Acme\, Inc.\"' ... 

约分辨名称中转义字符的更多信息,请参见this article由Richard L.米勒。

+0

当我尝试获得:C:\ Program Files \ WindowsApps \ Microsoft.DesktopAppConverter_1.0.0.0_x64__8wekyb3d8bbwe \ DesktopAppConverter.ps1:无法找到接受参数'Inc.'的位置参数。 – mikecousins

+0

你从PowerShell运行过吗? –

+0

我从Powershell的DesktopAppConverter应用程序运行它。 – mikecousins

0

根据有关appxmanifest可以,只要发布者的名称用双引号(“)包围包括发布者名称逗号没有问题,微软文档:

https://msdn.microsoft.com/en-us/library/windows/apps/br211441.aspx

所以真正的问题是如何用引号通发布者名称AppConverter

的解决方案似乎是表示“与\” \”通过发行这样的时候:

-Publisher 'CN=\"\"Company, Name\"\"' 

完整的命令在这里:

DesktopAppConverter.exe -Installer myInstaller.exe -InstallerArguments "/S" -Destination . -PackageName "MyApp" -Publisher 'CN=\"\"Company, Name\"\"' -Version 0.0.0.1 -MakeAppx 

但是似乎在DesktopAppConverter的错误。结果我得到的是这样的:

CN =“公司名称

第二届”从结果失踪。我不确定为什么DesktopAppConverter无法识别第二个“\”特殊字符,但是这种情况,所以我们不幸被卡在这里。

更新:找到解决方案。通过试验和错误,我发现添加双引号“”有助于识别第二个报价。因此,以下工作:

-Publisher 'CN=\"\"Company, Name""\"\"' 
+0

我试过这个解决方案,它不起作用,我仍然从MakeAppX –

0

不支持在桌面应用程序转换(DAC)的发布者参数中包含逗号。这是因为此值用于填充AppxManifest.xml文件中的Identity节点中的Publisher元素(包含在DAC生成的APPX中)

示例AppxManifest.xml文件中的测试如下所示:

<Identity Version="0.0.0.2" Publisher="CN=Awesome,Apps-Inc" ProcessorArchitecture="x86" Name="MyNotesFW"/>

当您尝试创建APPX文件,你会得到这样的错误:

MakeAppx:错误:错误信息:错误C00CE169:应用程序清单验证错误:应用程序清单必须按照有效模式:第3行,第58列,原因:'CN = Awesome,Apps-Inc'违反了模式约束' (CN | L | O | OU |电子| C | S | STREET | T | G | I | SN | DC | SERIALNUMBER |说明| POSTALCODE |邮政信箱|电话| X21Address | dnQualifier |(OID(0 |。[1- 9)[0-9] )(。(0 | [1-9] [0-9]))+))=(([^,+ =“<>#;])+ |”。 (OID。“),((CN | L | O | OU | E | C | S | ST | T | G | I | SN | DC | SERIALNUMBER |说明| PostalCode | POBox |电话| X21Address | dnQualifier | (0 | [1-9] [0-9])(。(0 | [1-9] [0-9] ))+))=(([^,+ =“<>#; )+ |“。”)))*'。

值为'CN = Awesome,Apps-Inc'的'Publisher'属性未能解析。

相关问题