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'屬性未能解析。

相關問題