diff --git a/src/Cake.Common.Tests/Unit/Tools/SignTool/SignToolSignRunnerTests.cs b/src/Cake.Common.Tests/Unit/Tools/SignTool/SignToolSignRunnerTests.cs index 1e9c2a049b..e9e2035768 100644 --- a/src/Cake.Common.Tests/Unit/Tools/SignTool/SignToolSignRunnerTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/SignTool/SignToolSignRunnerTests.cs @@ -480,6 +480,34 @@ public void Should_Call_Sign_Tool_With_Correct_Parameters_With_Use_Machine_Store // Then Assert.Equal("SIGN /f \"/Working/cert.pfx\" /p secret /sm /s \"Special Test Store\" \"/Working/a.dll\"", result.Args); } + + [Fact] + public void Should_Call_Sign_Tool_With_Correct_Parameters_With_Cryptographic_Service_Provider() + { + // Given + var fixture = new SignToolSignRunnerFixture(); + fixture.Settings.CspName = "Test Service Provider"; + + // When + var result = fixture.Run(); + + // Then + Assert.Equal("SIGN /f \"/Working/cert.pfx\" /p secret /csp \"Test Service Provider\" \"/Working/a.dll\"", result.Args); + } + + [Fact] + public void Should_Call_Sign_Tool_With_Correct_Parameters_With_Private_Key_Container_Name() + { + // Given + var fixture = new SignToolSignRunnerFixture(); + fixture.Settings.PrivateKeyContainerName = "[{{password}}]=TestContainerName"; + + // When + var result = fixture.Run(); + + // Then + Assert.Equal("SIGN /f \"/Working/cert.pfx\" /p secret /kc \"[{{password}}]=TestContainerName\" \"/Working/a.dll\"", result.Args); + } } } } \ No newline at end of file diff --git a/src/Cake.Common/Tools/SignTool/SignToolSignRunner.cs b/src/Cake.Common/Tools/SignTool/SignToolSignRunner.cs index 624c49c116..d712951ae5 100644 --- a/src/Cake.Common/Tools/SignTool/SignToolSignRunner.cs +++ b/src/Cake.Common/Tools/SignTool/SignToolSignRunner.cs @@ -241,6 +241,13 @@ private ProcessArgumentBuilder GetArguments(FilePath[] absoluteAssemblyPaths, Si builder.Append("/sm"); } + // open a specific certificate store + if (!string.IsNullOrWhiteSpace(settings.StoreName)) + { + builder.Append("/s"); + builder.AppendQuoted(settings.StoreName); + } + // Cryptographic Service Provider if (!string.IsNullOrEmpty(settings.CspName)) { @@ -255,13 +262,6 @@ private ProcessArgumentBuilder GetArguments(FilePath[] absoluteAssemblyPaths, Si builder.AppendQuoted(settings.PrivateKeyContainerName); } - // open a specific certificate store - if (!string.IsNullOrWhiteSpace(settings.StoreName)) - { - builder.Append("/s"); - builder.AppendQuoted(settings.StoreName); - } - // Target Assemblies to sign. foreach (var path in absoluteAssemblyPaths) {