Cannot import the following key file: tSQLtOfficialSigningKey.pfx when running building tSLQt

只愿长相守 提交于 2021-01-29 07:44:43

问题


I am trying to run tSQLt solution locally by following instructions in the tSQLt\Build\Install the tSQLt build.docx.

Re-built tSQLtCLR solution:

1>------ Rebuild All started: Project: tSQLtCLR, Configuration: Debug Any CPU ------
2>------ Rebuild All started: Project: tSQLtTestUtilCLR, Configuration: Debug Any CPU ------
3>------ Rebuild All started: Project: tSQLtExternalAccessKey, Configuration: Debug Any CPU ------
4>------ Rebuild All started: Project: UnsignedEmpty, Configuration: Debug Any CPU ------
1>  tSQLtCLR -> E:\Source\tSQLt\tSQLtCLR\tSQLtCLR\bin\Debug\tSQLtCLR.dll
2>  tSQLtTestUtilCLR -> E:\Source\tSQLt\tSQLtCLR\tSQLtTestUtilCLR\bin\Debug\tSQLtTestUtilCLR.dll
3>  tSQLtExternalAccessKey -> E:\Source\tSQLt\tSQLtCLR\tSQLtExternalAccessKey\bin\Debug\tSQLtExternalAccessKey.dll
4>  UnsignedEmpty -> E:\Source\tSQLt\tSQLtCLR\UnsignedEmpty\bin\Debug\UnsignedEmpty.dll
========== Rebuild All: 4 succeeded, 0 failed, 0 skipped ==========

I've create self-signed certificate:

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365

Then I've created pfx file:

openssl pkcs12 -export -out E:\Source\tSQLt\tSQLtCLR\OfficialSigningKey\tSQLtOfficialSigningKey.pfx -inkey key.pem -in cert.pem

Then I double clicked on that new pfx file and imported it for current user.

Finally run Menu / Tools / tSQLt local Dev_tSQL and getting following error:

+-------------------+
: Starting BUILD    :
+-------------------+
NAnt 0.92 (Build 0.92.4543.0; release; 2012-06-09)
Copyright (C) 2001-2012 Gerry Shaw
http://nant.sourceforge.net

Buildfile: file:///E:/Source/tSQLt/Build/tSQLt.build
Target framework: Microsoft .NET Framework 4.0
Target(s) specified: all 


init:


init.tSQLt:

   [delete] Deleting directory 'E:\Source\tSQLt\Build\temp'.
    [mkdir] Creating directory 'E:\Source\tSQLt\Build\temp'.

clr.compile:

     [echo] Compile CLR Command: "C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" tSQLtCLR.csproj /p:Configuration=CruiseControl /nologo
     [exec] Build started 2019-08-11 10:47:46 AM.
     [exec] Project "E:\Source\tSQLt\tSQLtCLR\tSQLtCLR\tSQLtCLR.csproj" on node 1 (default targets).
     [exec] C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2482,5): error MSB3325: Cannot import the following key file: tSQLtOfficialSigningKey.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_C20B79DE0583A5C1 [E:\Source\tSQLt\tSQLtCLR\tSQLtCLR\tSQLtCLR.csproj]
     [exec] C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2482,5): error MSB3321: Importing key file "tSQLtOfficialSigningKey.pfx" was canceled. [E:\Source\tSQLt\tSQLtCLR\tSQLtCLR\tSQLtCLR.csproj]
     [exec] Done Building Project "E:\Source\tSQLt\tSQLtCLR\tSQLtCLR\tSQLtCLR.csproj" (default targets) -- FAILED.
     [exec] 
     [exec] Build FAILED.
     [exec] 
     [exec] "E:\Source\tSQLt\tSQLtCLR\tSQLtCLR\tSQLtCLR.csproj" (default target) (1) ->
     [exec] (ResolveKeySource target) -> 
     [exec]   C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2482,5): error MSB3325: Cannot import the following key file: tSQLtOfficialSigningKey.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_C20B79DE0583A5C1 [E:\Source\tSQLt\tSQLtCLR\tSQLtCLR\tSQLtCLR.csproj]
     [exec]   C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2482,5): error MSB3321: Importing key file "tSQLtOfficialSigningKey.pfx" was canceled. [E:\Source\tSQLt\tSQLtCLR\tSQLtCLR\tSQLtCLR.csproj]
     [exec] 
     [exec]     0 Warning(s)
     [exec]     2 Error(s)
     [exec] 
     [exec] Time Elapsed 00:00:00.49

BUILD FAILED

E:\Source\tSQLt\Build\tSQLt.build(53,4):
External Program Failed: cmd (return code was 1)

Total time: 0.8 seconds.

+-------------------+
: BUILD FAILED      :
+-------------------+

UPDATE:

After pfx file was generated and 4 of them were replaced in the project. After that I open tSQLtCLR solution and went to each project properties (except UnsignedEmpty project), then to the Signing tab and there I tick `Sign the assembly" tick, choose the key. It asked for password I didn't entered any, just clicked OK as the key was created without password. Then I clean/rebuild the solution and got the errors:

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(3214,5): error MSB3325: Cannot import the following key file: tSQLtOfficialSigningKey.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_FAD69C25E7450957
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(3214,5): error MSB3321: Importing key file "tSQLtOfficialSigningKey.pfx" was canceled.
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(3214,5): error MSB3325: Cannot import the following key file: tSQLtOfficialSigningKey.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_3A487AA7CCDAEF2F
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(3214,5): error MSB3321: Importing key file "tSQLtOfficialSigningKey.pfx" was canceled.
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(3214,5): error MSB3325: Cannot import the following key file: tSQLtOfficialSigningKey.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_5C6CEC0DAE821947
3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(3214,5): error MSB3321: Importing key file "tSQLtOfficialSigningKey.pfx" was canceled.
4>  UnsignedEmpty -> E:\Source\tSQLt\tSQLtCLR\UnsignedEmpty\bin\Debug\UnsignedEmpty.dll

回答1:


The key is indeed password protected. You need to overwrite it with your own key locally.

Make sure you mark the file as exception in Git should you plan to do a pull request in the future.



来源:https://stackoverflow.com/questions/57440769/cannot-import-the-following-key-file-tsqltofficialsigningkey-pfx-when-running-b

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!