【发布时间】:2017-02-20 22:49:12
【问题描述】:
我用 SNK 文件签署我的 Dll。通过 Visual Studio 构建可以毫无问题地完成此操作。
现在我想验证我真正给它们起一个强名称的 DLL。我找到了this powershell script,但我认为 powershell 讨厌我的路径。
Clear-Host
$path="C:\Users\MyName\Desktop\BuildOutput\Debug"
$snPath = "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sn.exe"
foreach ($item in Get-ChildItem $path -Recurse -Include *.dll, *.exe)
{
$reportLine = $item.FullName + "," + $item.Extension
#validate integrity
$expression = $snPath + ' -vf "' + $item.FullName +'"'
$verify = Invoke-Expression $expression
$isValid = $verify | Select-String -Pattern "is valid"
if($isValid)
{
$reportLine = $reportLine + ",ist signiert"
}
else
{
$reportLine = $reportLine + ",ist nicht signiert"
}
#extract token
$expression = $snPath + ' -Tp "' + $item.FullName +'"'
$result = Invoke-Expression $expression
$tokenString = $result | Select-String -Pattern "key token is"
if($tokenString)
{
$token = $tokenString.Tostring().Substring(20)
$reportLine = $reportLine + "," +$token
}
$reportLine
}
我的错误是
行内:1 个字符:19
- C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 ...
- ~~~
- CategoryInfo : ObjectNotFound: (x86:String) [], CommandNotFoundException
- FullyQualifiedErrorId : CommandNotFoundException
我翻译了更多错误信息。
术语“x86”未被识别为 cmdlet、函数、脚本文件或可执行文件的名称。 检查名称的拼写,或者路径是否正确(如果包含),然后重试。
我必须逃离 x86 吗?如果是的话 - 我该怎么做?我试过this。
我试过了,结果都是一样的。
$snPath = "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sn.exe"
$snPath = ${env:CommonProgramFiles(x86)} + "\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sn.exe"
$snPath = ${env:ProgramFiles(x86)} + "\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sn.exe"
$snPath = [Environment]::GetEnvironmentVariable("ProgramFiles(x86)") + + "\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sn.exe"
Powershell 版本
专业:5
未成年人:1
建造:14393
修订:103
编辑
我修复了我的 snPath
我举了更多的例子
更多错误信息
【问题讨论】:
标签: powershell exception powershell-2.0 powershell-3.0 sn