2017-01-11 47 views
1

VS2015がインストールされているいくつかの開発マシンで動作するClickonceソリューションがあります。しかし、このsignFileエラーが発生したビルドサーバーでは動作しません。私はエラーMSB4018:ビルドサーバーで「SignFile」タスクが予期せず失敗しました

  • ビルドツール2015更新3
  • .NETをインストールした4.6.2 SDK
  • Windowsソフトウェア開発キット

しかしapparantlyとき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() 

答えて

1

エラーは、次の方法である、Microsoft.Build.Tasks.Deployment.ManifestUtilities.SecurityUtilitiesline 195にスローされます。

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.CurrentDirectorynullを返したが、より顕著つToolLocationHelper.GetPathToDotNetFrameworkSdkFile(ToolName(), TargetDotNetFrameworkVersion.Version35)も返したことだったということでしたnull

上記のコードは、クラスの特定のバージョンのスナップショットのみですが、ハードコードされた列挙型の値TargetDotNetFrameworkVersion.Version35問題がビルドツール2015更新3よりも他の.NET SDKのバージョンに依存していることであることを私に伝えます4.6.2。

UPDATE:

が特定のSDKのバージョンを識別しやすくするために、私はhttps://github.com/Microsoft/msbuild/releasesでアップデート3リリースからソースコードをプルダウン。液中にさらに掘り

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.2のサポートを追加しShared\FrameworkLocationHelper.cschangeが含まれていないと判断しました。あなたのフォローアップの質問に答えるには、4.6.1 SDKをインストールするには、というトリックが必要です。

UPDATE 2:

OPは、代替ソリューションを識別した:明示例えば、TargetFrameworkSDKToolsDirectoryプロパティの値を設定しますコマンドラインからmsbuild.exeを呼び出すときに、引数として/p:TargetFrameworkSDKToolsDirectory=PATH TO SIGNTOOL.EXE(?)を追加します。

+1

あなたはこれをどのように把握したか分かりませんが、感謝します。私はそれが依存しているSDKを知っているので、すべてインストールする必要はありませんか?今私はプロパティ/プロパティを設定することによってこれを回避しています:TargetFrameworkSDKToolsDirectory msbuildを呼び出すとき。 –

+0

この情報で更新された回答(私は正しいと思います!)。私がこれをどのように理解したかについては、エラーログの先頭近くで参照されているファイルと行番号に行くことから始めました。 'SignFile'タスクがツール/実行ファイルへのパスのパラメータを取っていないのを見たとき、私は' SignFile'タスクのソースコードを見る必要があることを知っていました。幸いにも、MSBuildは現在オープンソースです! – weir

+0

@dennis_ler - この回答にあなたの 'TargetFrameworkSDKToolsDirectory'修正を追加しました。 – weir

関連する問題