I looked into C:\Program Files\Microsoft.NET
and I can't see any SN.exe
file.
我看着C:\Program Files\Microsoft.我看不到任何锡。exe文件。
I have .NET 3.5 runtime installed; isn't that enough ?
我安装了。net 3.5运行时;难道这还不够吗?
5 个解决方案
#1
74
You need to install the Windows SDK 6.0a, not just the runtime.
您需要安装Windows SDK 6.0a,而不仅仅是运行时。
If you've installed VS2008, you'll find it's already installed, and sn.exe will be here:
如果你已经安装了VS2008,你会发现它已经安装好了,还有sn。exe将:
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\sn.exe
C:\Program Files\Microsoft sdk \ Windows \ v6.0A \ Bin \ sn.exe
Otherwise, if you don't have VS2008 installed, you can download the SDK individually here.
否则,如果您没有安装VS2008,您可以在这里单独下载SDK。
The file sn.exe is not available in the SDK. The current version of the SDK is 6.1, perhaps they removed sn.exe in this release.
文件sn。exe在SDK中不可用。当前版本的SDK是6.1,也许他们去掉了sn。exe这个版本。
#2
10
- open command prompt
- 打开命令提示符
- type
cd \
- 类型cd \
- type
dir /s sn.exe
- dir / s sn.exe类型
-
you will get output something like
你会得到一些类似的输出。
Volume in drive C has no label.
驱动器C的卷没有标签。
Volume Serial Number is XXXX-XXXX.
卷序号是XXXX-XXXX。
Directory of C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin
C:\Program Files\Microsoft sdk目录\ Windows \ v6.0A \ bin
11/07/2007 12:01 PM 95,728 sn.exe
1 File(s) 95,728 bytes
You found the directory :)
if not, there is no sn.exe
in your system. Install SDK then.
您找到了目录:)如果没有,就没有sn。exe在您的系统。安装SDK。
#4
3
I'm sure you have your reasons -- and there are definitely plenty cases where SN.exe
is unavoidable and/or appropriate (Delay Signing for one). (And I've +1'd the Q and the Accepted A and am not disputing their merit in any way so please disregard this if it doesn't apply in your case)
我相信你有你的理由——而且肯定有很多情况下SN。exe不可避免且/或适当(延迟签名)。(我有+1的Q和被接受的A,并且没有在任何方面争论他们的优点所以请忽略这一点,如果它不适用于你的情况)
Note that SN.exe
is rarely needed in practice - the wiring in Microft.<lang>.targets
that drive the compilers [and AL.exe
etc.] all [effectively] take the SignAssembly
flag in the .proj file into account and conditionally pass in the key to the compiler(s) etc. so it can do all the work in a single touch of the assembly inline (mainly for perf reasons).
注意,SN。在实践中很少需要exe——微ft的布线。
This logic also deals with the distinction between .snk
and .pfx
keys (which are password protected and get secreted into a Key Container). Depending on which form, there is then either a KeyContainerName
or KeyOriginatorFile
property resolved by Microsoft.Common.targets
in the Runtime directory - Search for ResolveKeySource
.
该逻辑还处理了.snk和.pfx键之间的区别(它们是密码保护的,并被隐藏到一个密钥容器中)。根据表单的不同,有一个KeyContainerName或KeyOriginatorFile属性,由Microsoft.Common解决。运行时目录中的目标——搜索ResolveKeySource。
If the reason you need to do a SN
is because you've just rewritten an assembly, the same pattern should generally hold, i.e. Mono.Cecil
and tools a la PostSharp (I assume, not confirmed) generally also take the same arguments and/or can be made to do the signing inline.
如果你需要做一个SN的原因是因为你刚刚重写了一个程序集,同样的模式也应该保持不变,即Mono。Cecil和工具a la PostSharp(我假设,没有确认)通常也采用相同的参数和/或可以进行内联的签名。
Microsoft.Common.targets excerpt
<Target Name="ResolveKeySource"
Condition="$(SignManifests) == 'true' or $(SignAssembly) == 'true'">
<ResolveKeySource ...
KeyFile="$(AssemblyOriginatorKeyFile)"
CertificateFile="$(ManifestKeyFile)"
SuppressAutoClosePasswordPrompt="$(BuildingInsideVisualStudio)">
<Output TaskParameter="ResolvedKeyFile" PropertyName="KeyOriginatorFile" ..."/>
<Output TaskParameter="ResolvedKeyContainer" PropertyName="KeyContainerName" ... "/>
Microsoft.CSharp.targets excerpt
<Csc ...
KeyContainer="$(KeyContainerName)"
KeyFile="$(KeyOriginatorFile)" />
For completeness, here's how to programmatically infer the SDK path relevant to the target you are compiling (tested on 4.0 but same approach is possible all the way back to 2.0, i.e. Microsoft.Common.targets
has processed this data for some time):
为了完整起见,这里是如何以编程方式推断与您正在编译的目标相关的SDK路径(在4.0中测试,但同样的方法可能会一直追溯到2.0,即Microsoft.Common)。目标已经处理了这个数据一段时间):
<Target Name="ResolveSNToolPath" Condition=" 'true' == '$(SignAssembly)' ">
<PropertyGroup>
<_SdkToolsBinDir Condition=" '' == '$(_SdkToolsBinDir)' ">$(TargetFrameworkSDKToolsDirectory)</_SdkToolsBinDir>
<SNToolPath Condition=" '' == '$(SNToolPath)' ">$(_SdkToolsBinDir)SN.exe</SNToolPath>
</PropertyGroup>
<Error Condition=" 'true' == '$(SignAssembly)' AND !EXISTS( '$(SNToolPath)' )"
Text="In order to resign the assembly, this package requires access to the SN.EXE tool from the Windows Platform SDK, which was not found.
The location derived was "$(SNToolPath)".
Please either:
1) supply a correct path to your SDK Tools bin directory containing SN.EXE by setting %24(_SdkToolsBinDir) or %24(TargetFrameworkSDKToolsDirectory)
OR
2) supply a correct complete path to your SN.EXE signing tool by setting %24(SNToolPath)" />
</Target>
For total completeness, here's how you would leverage the outputs of this process to run SN.exe
为了完整起见,下面是如何利用这个过程的输出来运行SN.exe。
<Target Name="ResignMyAssembly" Condition="$(SignAssembly) == 'true'">
<Exec Condition=" '$(KeyContainerName)' != '' "
Command=""$(SNToolPath)" -Rca "@(MyAssembly)" "$(KeyContainerName)" " />
<Exec Condition=" '$(KeyContainerName)' == '' "
Command=""$(SlpsSdkProtectSnTool)" -Ra "@(MyAssembly)" "$(KeyOriginatorFile)" " />
#5
1
Nope, looks like you need the SDK for that :(
不,看起来你需要SDK
FYI, the Runtime itself would not be under C:\Program Files\Microsoft.NET
-- all it's files live [only] under C:\Windows\Microsoft.NET\vXXXXXX\
FYI,运行时本身不属于c:microsoft。净——这是所有文件住在C:\Windows\ Microsoft.NET \ vXXXXXX \[只]
#1
74
You need to install the Windows SDK 6.0a, not just the runtime.
您需要安装Windows SDK 6.0a,而不仅仅是运行时。
If you've installed VS2008, you'll find it's already installed, and sn.exe will be here:
如果你已经安装了VS2008,你会发现它已经安装好了,还有sn。exe将:
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\sn.exe
C:\Program Files\Microsoft sdk \ Windows \ v6.0A \ Bin \ sn.exe
Otherwise, if you don't have VS2008 installed, you can download the SDK individually here.
否则,如果您没有安装VS2008,您可以在这里单独下载SDK。
The file sn.exe is not available in the SDK. The current version of the SDK is 6.1, perhaps they removed sn.exe in this release.
文件sn。exe在SDK中不可用。当前版本的SDK是6.1,也许他们去掉了sn。exe这个版本。
#2
10
- open command prompt
- 打开命令提示符
- type
cd \
- 类型cd \
- type
dir /s sn.exe
- dir / s sn.exe类型
-
you will get output something like
你会得到一些类似的输出。
Volume in drive C has no label.
驱动器C的卷没有标签。
Volume Serial Number is XXXX-XXXX.
卷序号是XXXX-XXXX。
Directory of C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin
C:\Program Files\Microsoft sdk目录\ Windows \ v6.0A \ bin
11/07/2007 12:01 PM 95,728 sn.exe
1 File(s) 95,728 bytes
You found the directory :)
if not, there is no sn.exe
in your system. Install SDK then.
您找到了目录:)如果没有,就没有sn。exe在您的系统。安装SDK。
#3
#4
3
I'm sure you have your reasons -- and there are definitely plenty cases where SN.exe
is unavoidable and/or appropriate (Delay Signing for one). (And I've +1'd the Q and the Accepted A and am not disputing their merit in any way so please disregard this if it doesn't apply in your case)
我相信你有你的理由——而且肯定有很多情况下SN。exe不可避免且/或适当(延迟签名)。(我有+1的Q和被接受的A,并且没有在任何方面争论他们的优点所以请忽略这一点,如果它不适用于你的情况)
Note that SN.exe
is rarely needed in practice - the wiring in Microft.<lang>.targets
that drive the compilers [and AL.exe
etc.] all [effectively] take the SignAssembly
flag in the .proj file into account and conditionally pass in the key to the compiler(s) etc. so it can do all the work in a single touch of the assembly inline (mainly for perf reasons).
注意,SN。在实践中很少需要exe——微ft的布线。
This logic also deals with the distinction between .snk
and .pfx
keys (which are password protected and get secreted into a Key Container). Depending on which form, there is then either a KeyContainerName
or KeyOriginatorFile
property resolved by Microsoft.Common.targets
in the Runtime directory - Search for ResolveKeySource
.
该逻辑还处理了.snk和.pfx键之间的区别(它们是密码保护的,并被隐藏到一个密钥容器中)。根据表单的不同,有一个KeyContainerName或KeyOriginatorFile属性,由Microsoft.Common解决。运行时目录中的目标——搜索ResolveKeySource。
If the reason you need to do a SN
is because you've just rewritten an assembly, the same pattern should generally hold, i.e. Mono.Cecil
and tools a la PostSharp (I assume, not confirmed) generally also take the same arguments and/or can be made to do the signing inline.
如果你需要做一个SN的原因是因为你刚刚重写了一个程序集,同样的模式也应该保持不变,即Mono。Cecil和工具a la PostSharp(我假设,没有确认)通常也采用相同的参数和/或可以进行内联的签名。
Microsoft.Common.targets excerpt
<Target Name="ResolveKeySource"
Condition="$(SignManifests) == 'true' or $(SignAssembly) == 'true'">
<ResolveKeySource ...
KeyFile="$(AssemblyOriginatorKeyFile)"
CertificateFile="$(ManifestKeyFile)"
SuppressAutoClosePasswordPrompt="$(BuildingInsideVisualStudio)">
<Output TaskParameter="ResolvedKeyFile" PropertyName="KeyOriginatorFile" ..."/>
<Output TaskParameter="ResolvedKeyContainer" PropertyName="KeyContainerName" ... "/>
Microsoft.CSharp.targets excerpt
<Csc ...
KeyContainer="$(KeyContainerName)"
KeyFile="$(KeyOriginatorFile)" />
For completeness, here's how to programmatically infer the SDK path relevant to the target you are compiling (tested on 4.0 but same approach is possible all the way back to 2.0, i.e. Microsoft.Common.targets
has processed this data for some time):
为了完整起见,这里是如何以编程方式推断与您正在编译的目标相关的SDK路径(在4.0中测试,但同样的方法可能会一直追溯到2.0,即Microsoft.Common)。目标已经处理了这个数据一段时间):
<Target Name="ResolveSNToolPath" Condition=" 'true' == '$(SignAssembly)' ">
<PropertyGroup>
<_SdkToolsBinDir Condition=" '' == '$(_SdkToolsBinDir)' ">$(TargetFrameworkSDKToolsDirectory)</_SdkToolsBinDir>
<SNToolPath Condition=" '' == '$(SNToolPath)' ">$(_SdkToolsBinDir)SN.exe</SNToolPath>
</PropertyGroup>
<Error Condition=" 'true' == '$(SignAssembly)' AND !EXISTS( '$(SNToolPath)' )"
Text="In order to resign the assembly, this package requires access to the SN.EXE tool from the Windows Platform SDK, which was not found.
The location derived was "$(SNToolPath)".
Please either:
1) supply a correct path to your SDK Tools bin directory containing SN.EXE by setting %24(_SdkToolsBinDir) or %24(TargetFrameworkSDKToolsDirectory)
OR
2) supply a correct complete path to your SN.EXE signing tool by setting %24(SNToolPath)" />
</Target>
For total completeness, here's how you would leverage the outputs of this process to run SN.exe
为了完整起见,下面是如何利用这个过程的输出来运行SN.exe。
<Target Name="ResignMyAssembly" Condition="$(SignAssembly) == 'true'">
<Exec Condition=" '$(KeyContainerName)' != '' "
Command=""$(SNToolPath)" -Rca "@(MyAssembly)" "$(KeyContainerName)" " />
<Exec Condition=" '$(KeyContainerName)' == '' "
Command=""$(SlpsSdkProtectSnTool)" -Ra "@(MyAssembly)" "$(KeyOriginatorFile)" " />
#5
1
Nope, looks like you need the SDK for that :(
不,看起来你需要SDK
FYI, the Runtime itself would not be under C:\Program Files\Microsoft.NET
-- all it's files live [only] under C:\Windows\Microsoft.NET\vXXXXXX\
FYI,运行时本身不属于c:microsoft。净——这是所有文件住在C:\Windows\ Microsoft.NET \ vXXXXXX \[只]