Delay signing Visual Studio and XamlBuildTask

While working on signing assemblies you may run into a problem I encountered this morning so here goes…

Problem XamlBuildTask fails when referencing a Delay Signed assembly

To see this in action try the following

Create a Workflow Console Application (WorkflowConsoleApp1)

Create an Activity Library (ActivityLibrary1)

Reference ActivityLibrary1 from WorkflowConsoleApp1

Set ActivityLibrary1 to Delay Sign

Build and you will get this error

Build error occurred in the XAML MSBuild task: ‘Could not load file or assembly ‘file:///d:\spike\ActivityLibrary1\bin\Debug\ActivityLibrary1.dll’ or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key.

Problem: Visual Studio does not correctly update the state of the Delay Sign checkbox when loading a project

To make this problem even worse, try this.

Uncheck Sign the assembly

Close the solution

Open it again

Open the project properties

Check Sign the assembly

Verify that Delay sign only is unchecked

Build the solution – the error still occurs – why?

Unload the project and edit it

Look for DelaySign in the project XML – even though the checkbox is unchecked, DelaySign is true in the project file