我有一个clickonce解决方案,适用于安装了VS 2015的多台开发人员计算机。但是,它不能在我们的构建服务器上工作,它带有这个signFile错误。我已经安装了
但是显然signtool.exe的路径没有正确设置。如果我禁用了清单的签名,它将继续,但是会出现setup.bin缺失错误。
有没有人知道如何解决SignFile问题?
[_DeploymentComputeClickOnceManifestInfo] Using "SignFile" task from assembly "Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
[_DeploymentComputeClickOnceManifestInfo] SignFile
[SignFile] C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(3616, 5): error MSB4018: The "SignFile" task failed unexpectedly.
System.ArgumentNullException: Value cannot be null.
Parameter name: path1
at System.IO.Path.Combine(String path1, String path2, String path3)
at Microsoft.Build.Tasks.Deployment.ManifestUtilities.SecurityUtilities.GetPathToTool(ResourceManager resources)
at Microsoft.Build.Tasks.Deployment.ManifestUtilities.SecurityUtilities.SignPEFile(X509Certificate2 cert, Uri timestampUrl, String path, ResourceManager resources, Boolean useSha256)
at Microsoft.Build.Tasks.Deployment.ManifestUtilities.SecurityUtilities.SignFileInternal(X509Certificate2 cert, Uri timestampUrl, String path, Boolean targetFrameworkSupportsSha256, ResourceManager resources)
at Microsoft.Build.Tasks.Deployment.ManifestUtilities.SecurityUtilities.SignFile(X509Certificate2 cert, Uri timestampUrl, String path)
at Microsoft.Build.Tasks.Deployment.ManifestUtilities.SecurityUtilities.SignFile(String certThumbprint, Uri timestampUrl, String path, String targetFrameworkVersion)
at Microsoft.Build.Tasks.SignFile.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
答案 0 :(得分:1)
Microsoft.Build.Tasks.Deployment.ManifestUtilities.SecurityUtilities
的{{3}}引发了错误,该错误采用以下方法:
internal static string GetPathToTool()
{
string pathToDotNetFrameworkSdkFile = ToolLocationHelper.GetPathToDotNetFrameworkSdkFile(ToolName(), TargetDotNetFrameworkVersion.Version35);
if (pathToDotNetFrameworkSdkFile == null)
{
pathToDotNetFrameworkSdkFile = Path.Combine(Environment.CurrentDirectory, ToolName());
}
if (!File.Exists(pathToDotNetFrameworkSdkFile))
{
pathToDotNetFrameworkSdkFile = null;
}
return pathToDotNetFrameworkSdkFile;
}
直接原因是Environment.CurrentDirectory
返回null
,但更突出的是[{1}}也返回了ToolLocationHelper.GetPathToDotNetFrameworkSdkFile(ToolName(), TargetDotNetFrameworkVersion.Version35)
。
上面的代码是该类特定版本的唯一快照,但硬编码的枚举值null
告诉我问题是 Build Tools 2015更新3 取决于除4.6.2之外的.Net SDK版本。
<强>更新强>
为了帮助确定特定的SDK版本,我从line 195的Update 3版本中删除了源代码。
TargetDotNetFrameworkVersion.Version35
进一步深入解决方案,我确定最新版本的Build Tools(您安装的那个)不包括添加对Framework 4.6.2的支持的https://github.com/Microsoft/msbuild/releases到 internal static string GetPathToTool(System.Resources.ResourceManager resources)
{
#pragma warning disable 618 // Disabling warning on using internal ToolLocationHelper API. At some point we should migrate this.
string toolPath = ToolLocationHelper.GetPathToWindowsSdkFile(ToolName, TargetDotNetFrameworkVersion.VersionLatest, VisualStudioVersion.VersionLatest);
if (toolPath == null)
toolPath = ToolLocationHelper.GetPathToWindowsSdkFile(ToolName, TargetDotNetFrameworkVersion.Version45, VisualStudioVersion.Version110);
if (toolPath == null)
toolPath = Path.Combine(ToolLocationHelper.GetPathToDotNetFrameworkSdk(TargetDotNetFrameworkVersion.Version40, VisualStudioVersion.Version100), "bin", ToolName);
if (toolPath == null)
toolPath = Path.Combine(Directory.GetCurrentDirectory(), ToolName);
if (!File.Exists(toolPath))
throw new ApplicationException(String.Format(CultureInfo.CurrentCulture, resources.GetString("SecurityUtil.SigntoolNotFound"), toolPath));
return toolPath;
#pragma warning restore 618
}
。因此,要回答您的后续问题,安装4.6.1 SDK应该可以解决问题。
更新2:
OP确定了另一种解决方案:明确设置Shared\FrameworkLocationHelper.cs
属性的值,例如通过从命令行调用TargetFrameworkSDKToolsDirectory
时添加/p:TargetFrameworkSDKToolsDirectory=PATH TO SIGNTOOL.EXE(?)
作为参数。