自动进入密码在SN.EXE [英] Auto-entering Password In Sn.exe

查看:146
本文介绍了自动进入密码在SN.EXE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建后生成事件来执行以下操作:

I need to create post build event to perform the following:

sn -i MyKey.pfx MyKeyContainerName
tlbimp $(ConfigurationName)\MyCom.tlb /out:$(ConfigurationName)\NETMyCom.dll /keycontainer:MyKeyContainerName
sn -d MyKeyContainerName

在Visual Studio的执行它需要一个密码,并等待用户指定它,失败的第一个声明。

When the Visual Studio executes the 1st statement it requires a password and waits until the user specifies it and fails.

微软(R).NET Framework中的强
名称实用程序版本2.0.50727.42
版权所有(c)Microsoft公司。
保留所有权利。

Microsoft (R) .NET Framework Strong Name Utility Version 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved.

对于PKCS输入密码#12键
档:无法解析PKCS#12
BLOB在mykey.pfx - 句柄
无效

Enter the password for the PKCS#12 key file: Failed to parse the PKCS#12 blob in mykey.pfx -- The handle is invalid.

我尝试使用SN命令行参数指定密码,但我看不到的方式来做到这一点。

I tried to specify the password using sn command line arguments, but I could not see a way to do it.

请帮忙。

问候,
。希尔米

Regards, Hilmi.

推荐答案

如果你像我一样没有使用TFS或MSBUILD建立,那么至少有2其他方式:

if like me, you are not using TFS or MSBUILD to build, then there are at least 2 other ways:

)运行从脚本SN.EXE,写密码标准输入

请参见这里一个C#例如:

请注意:与SN.EXE的.NET4版本,它似乎是不可能执行它作为外部进程(至少在Windows XP),并写入密码标准输入(我试图与蟒蛇+与C#和SN.EXE似乎无需等待密码输入刚刚退出)。

note: with the .NET4 version of sn.exe it seems to be impossible to execute it as external process (at least on Windows XP), and write the password to stdin (I tried with python + with C#, and sn.exe seems to just exit without waiting for password input).

二)使用SN。 exe文件进行重新签名密码,使用已安装PFX。

如果您已经安装PFX文件,那么你可能知道容器名称(通常是Visual Studio中使用一个名称,如VS_KEY_ABAB1234ABAB1234)

If you have already installed the pfx file, then you might know the container name (usually Visual Studio uses a name like VS_KEY_ABAB1234ABAB1234)

如果像我一样,你不知道或记得容器名称,那么就重新安装PFX文件

If, like me, you do not know or remember the container name, then just re-install the pfx file:

sn -i myPfxFile VS_KEY_ABAB1234ABAB1234

SN.EXE会提示您输入密码,因为它安装在PFX文件的证书。

sn.exe will prompt you for a password, as it installs the certificate in the pfx file.

您可以然后进行SN。 exe文件重新签上您的组装,没有任何提示输入密码:

You can then make sn.exe re-sign your assembly, without any prompt for password:

sn -Rca myAssembly.dll myVSkey

上面可以在构建脚本被使用,因为不需要相互作用: - )

The above can be used in a build script, as no interaction is required :-)

NB记得要检查签约的实际工作:

NB remember to check that the signing actually works:

sn -v myAssembly.dll

这篇关于自动进入密码在SN.EXE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆