I have the following code in my TFSBuild.proj file. The person kicking off the build supplies the version number, for example: /p:MyVersion=1.2.3.4
<PropertyGroup>
<Thumbprint>1234567890abcde12345678909abcde123456789</Thumbprint>
</PropertyGroup>
<Target Name="ClickOnce" Condition=" '$(MyVersion)'!='' ">
<ItemGroup>
<EntryPoint Include="$(DropLocation)\$(BuildNumber)\Debug\TestWpfApplication.exe" />
<Dependency Include="$(DropLocation)\$(BuildNumber)\Debug\**\*.exe;$(DropLocation)\$(BuildNumber)\Debug\**\*.dll" Exclude="@(EntryPoint)" />
<File Include="$(DropLocation)\$(BuildNumber)\Debug\**\*.*" Exclude="@(EntryPoint);@(Dependency)" />
</ItemGroup>
<GenerateApplicationManifest
EntryPoint="@(EntryPoint)"
Dependencies="@(Dependency)"
AssemblyVersion="$(MyVersion)"
Files="@(File)">
<Output
ItemName="ApplicationManifest"
TaskParameter="OutputManifest"/>
</GenerateApplicationManifest>
<Message Text="%(ApplicationManifest.FullPath)" />
<Message Text="$(Thumbprint)" />
<ItemGroup>
<SignTarget Include="%(ApplicationManifest.FullPath)" />
</ItemGroup>
<Message Text="@(SignTarget)" />
<SignFile
CertificateThumbprint="$(Thumbprint)"
SigningTarget="@(SignTarget)"/>
</Target>
<Target Name="AfterDropBuild" DependsOnTargets="ClickOnce"/>
</Project>
All of the messages return what I expect and the application manifest looks good. The problem is that the SignFile task returns a NullReferenceException. Here is the log file output:
Target "ClickOnce" in file "D:\BL\72\BuildType\TFSBuild.proj" from project "D:\BL\72\BuildType\TFSBuild.proj":
Using "GenerateApplicationManifest" task from assembly "Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "GenerateApplicationManifest"
Done executing task "GenerateApplicationManifest".
Task "Message"
D:\BL\72\BuildType\TestWpfApplication.exe.manifest
Done executing task "Message".
Task "Message"
1234567890abcde12345678909abcde123456789
Done executing task "Message".
Task "Message"
D:\BL\72\BuildType\TestWpfApplication.exe.manifest
Done executing task "Message".
Using "SignFile" task from assembly "Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "SignFile"
D:\BL\72\BuildType\TFSBuild.proj(255,9): error MSB4018: The "SignFile" task failed unexpectedly.
D:\BL\72\BuildType\TFSBuild.proj(255,9): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object.
D:\BL\72\BuildType\TFSBuild.proj(255,9): error MSB4018: at Microsoft.Build.Tasks.Deployment.ManifestUtilities.SecurityUtilities.SignFile(X509Certificate2 cert, Uri timestampUrl, String path)
D:\BL\72\BuildType\TFSBuild.proj(255,9): error MSB4018: at Microsoft.Build.Tasks.Deployment.ManifestUtilities.SecurityUtilities.SignFile(String certThumbprint, Uri timestampUrl, String path)
D:\BL\72\BuildType\TFSBuild.proj(255,9): error MSB4018: at Microsoft.Build.Tasks.SignFile.Execute()
D:\BL\72\BuildType\TFSBuild.proj(255,9): error MSB4018: at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)
Done executing task "SignFile" -- FAILED.
Done building target "ClickOnce" in project "TFSBuild.proj" -- FAILED.
Done Building Project "D:\BL\72\BuildType\TFSBuild.proj" (EndToEndIteration target(s)) -- FAILED.
Deferred Messages
Overriding target "SatelliteDllsProjectOutputGroup" in project "C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets" with target "SatelliteDllsProjectOutputGroup" from project "C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.WinFX.targets".
Build FAILED."D:\BL\72\BuildType\TFSBuild.proj" (EndToEndIteration target) (1) ->
(ClickOnce target) ->
D:\BL\72\BuildType\TFSBuild.proj(255,9): error MSB4018: The "SignFile" task failed unexpectedly.
D:\BL\72\BuildType\TFSBuild.proj(255,9): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object.
D:\BL\72\BuildType\TFSBuild.proj(255,9): error MSB4018: at Microsoft.Build.Tasks.Deployment.ManifestUtilities.SecurityUtilities.SignFile(X509Certificate2 cert, Uri timestampUrl, String path)
D:\BL\72\BuildType\TFSBuild.proj(255,9): error MSB4018: at Microsoft.Build.Tasks.Deployment.ManifestUtilities.SecurityUtilities.SignFile(String certThumbprint, Uri timestampUrl, String path)
D:\BL\72\BuildType\TFSBuild.proj(255,9): error MSB4018: at Microsoft.Build.Tasks.SignFile.Execute()
D:\BL\72\BuildType\TFSBuild.proj(255,9): error MSB4018: at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)
I have tried all that I know to attempt to resolve this issue. I even got an unreleased hotfix associated with MSB4018 - no luck. Does anyone have any ideas?
James Bristow, Developer/Software Configuration Manager