MSBuild не может подписать манифест ClickOnce с использованием временного ключа (ошибки MSB3326 и MSB3321)

Я пытаюсь создать ClickOnceWindows Forms проект (.NET 3.5 / Visual Studio 2010) на компьютере под управлением Windows Server.(In an effort to automate the build process with Гудзон CI.)

Для подписания манифеста ClickOnce я создал временный ключ в Visual Studio,temp.pfx, Я могу успешно построить и развернуть проект из Visual Studio на моей рабочей станции. Но когда работаетMSBuild на сервере я получаю следующие сообщения об ошибках:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1970,9): error MSB3326: Cannot import the following key file: . The key file may be password protected. To correct this, try to import the certificate again or import the certificate manually into the current user's personal certificate store. [C:.hudson\jobs[...].csproj]

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1970,9): error MSB3321: Importing key file "temp.pfx" was canceled. [C:.hudson\jobs[...].csproj]

Я попробовал все следующие вопросы и ответы без удачи:

Stack Overflow question Cannot import the keyfile 'blah.pfx' - error 'The keyfile may be password protected'

=> In my case, the error message does not indicate a name of a certificate store but says "the current user's personal certificate store" instead.

=> Even when trying the accepted answer with "Personal" as the container name (sn -i temp.pfx personal), it fails to parse the key:

Failed to parse the PKCS#12 blob in ALiS_TemporaryKey.pfx -- An internal error o ccurred.

Stack Overflow question Using MSBuild to sign ClickOnce or assembly results in error MSB3321

=> I tried the accepted answer, but the key file cannot be imported because "Either the user profile is not accessible or the private key that you are importing might require a cryptographic service provider that is not installed on your system"

=> The same happens if I try to import the file by double-clicking it in Windows Explorer (RobinDotNet's suggestion)

Stack Overflow question Signing assemblies with PFX files in MSBuild, Team Build, and TFS

=> The OP of that question was unsuccessful with the above two answers, too, but unfortunately not even the answers that he got would help me:

Log in as the user that runs MSBuild on the build machine, manually invoke MSBuild, and then type in the password when prompted.

=> I logged in and ran msbuild myproject.sln but it would not even prompt me for the password.

What finally fixed it for me was making the account under which TFS Build service runs an administrator on the local machine.

=> The account that runs Hudson (more precisely: Tomcat) already is a local administrator. I tried to run MSBuild from a "Run As Administrator" command line even and would get the same error messages still.

Update: Я попытался открыть решение в Visual Studio на том же сервере и построить его. Я получаю ту же ошибку. Когда я пытаюсь повторно импортировать файл PFX в свойствах проекта & apos; На вкладке подписи сообщается «неверный пароль». Если я попытаюсь импортировать тот же файл в том же решении в Visual Studio на моей рабочей станции и введу тот же пароль, он будет принят.

Update 2: Если я возьму старый временный ключ, который я сгенерировал с помощью Visual & # xA0; Studio & # xA0; 2008, он может быть успешно импортирован в хранилище сертификатов нашего сервера; любые временные ключи, которые я недавно создал с помощью Visual Studio 2010, не могут быть импортированы.

Update 3: Мне удалось создать новый & quot; временный ключ & quot; в Visual Studio на сервере и используйте его как на сервере, так и на моей рабочей станции для подписания манифеста ClickOnce. Я только не могу дать разумное объяснение этому - оба компьютера 64-битные, и я использую Visual Studio 2010 на обоих. Оба имеют установленную платформу .NET v3.5 и v4 (4.0.30319). Моя рабочая станция - Windows 7 Professional, а сервер -Windows Server 2008 Стандарт R2.

Ответы на вопрос(4)

Ваш ответ на вопрос