0

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
Dmitrij Kultasev
  • 5,447
  • 5
  • 44
  • 88

1 Answers1

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.

Sebastian Meine
  • 11,260
  • 29
  • 41
  • I generated pfx file out of my local cert/key. What's next? Do I need to replace tSQLt\tSQLtCLR\OfficialSigningKey\tSQLtOfficialSigningKey.pfx file with that? Any password configuration? – Dmitrij Kultasev Aug 10 '19 at 15:01
  • Yes, replace that file. No password configuration needed. – Sebastian Meine Aug 11 '19 at 01:03
  • I've updated the question. Could you please take a look? I'm still getting that error. – Dmitrij Kultasev Aug 11 '19 at 07:51
  • Can you open the CLR solution in VS and build it there once? If it builds in VS, then it should work in the script afterwards, too. If it doesn’t build, it should give as more info as to why. – Sebastian Meine Aug 11 '19 at 12:03
  • I've rebuilt the project and it still gives the same error. – Dmitrij Kultasev Aug 11 '19 at 12:18
  • When you created the new key, did you set a password? If so, try to recreate it without. – Sebastian Meine Aug 12 '19 at 16:27
  • Re-created the key without password (passkey was entered only). Replaced tSQLtOfficialSigningKey.pfx file in 4 locations (tSQLtCKR, OfficialSigningKey, tSQLtExternalAccessKey, tSQLtTestUtilCLR). Also imported it to windows, by doubleclicking on it it (then next, next...). Still getting the same error. – Dmitrij Kultasev Aug 12 '19 at 18:52
  • In Visual Studio, modify the project to not include the key. Then build it. Then add your key back in. Then build it again. If that doesn't help, go through those steps again, but use VS to create the key for you. – Sebastian Meine Aug 12 '19 at 23:04
  • what does it mean "use VS to create the key for you"? I've cloned the project to another directory, followed the steps from the instructions (basically needed just run Setup.bat file). Then open tSQtLCLR project and clean/re-build the solution. Did I need to do something else as this didn't help :( – Dmitrij Kultasev Aug 13 '19 at 05:36
  • could you please help? I almost finished main development part for faking of external synonyms so I want to add tests and try how is it going... – Dmitrij Kultasev Aug 19 '19 at 07:26
  • https://learn.microsoft.com/en-us/visualstudio/ide/managing-assembly-and-manifest-signing?view=vs-2019 – Sebastian Meine Aug 19 '19 at 11:37
  • 1
    Just as a side note, tSQLt is developed using TDD. To have your addition accepted, the tests need to cover your codebase equally well. Also think about all edge cases, like synonyms to procedures in another database that use a tabletype parameter. – Sebastian Meine Aug 19 '19 at 11:42
  • I support only views and tables currently – Dmitrij Kultasev Aug 19 '19 at 11:49
  • I updated the question, after signing the projects the solution doesn't build. – Dmitrij Kultasev Aug 21 '19 at 05:18
  • 1
    Now, I did recommend you use VS to generate a new key. Doesn’t look like you did that. – Sebastian Meine Aug 21 '19 at 10:40
  • finally! thanks! it's failing now but because of another reason. – Dmitrij Kultasev Aug 21 '19 at 11:22