Cannot set unknown member ‘Microsoft.TeamFoundation.Build.Workflow.Activities.MSBuild.AllowUntrustedCertificate’

The Problem:

I am using a custom activity in my build template using TFS 2010 and Visual Studio 2011. The workflow saves with no errors or warnings, but the build fails with the following message:

TF215097: An error occurred while initializing a build for build definition \Project\BuildDefinition: Cannot set unknown member ‘Microsoft.TeamFoundation.Build.Workflow.Activities.MSBuild.AllowUntrustedCertificate’.

The Investigation:

  • The error didn’t appear until AFTER I added my custom activity
  • If I removed the custom activity, the error remains
  • The error wouldn’t go away until I removed the MSBuild Activity
  • As soon as I add the custom activity, the MSBuild Activity became corrupted

After searching the web, I found only one useful link. The solution found there was to use Visual Studio 2010. That did not help me any because, for some unknown reason, the project in question would not compile in VS2010. There were nearly 80 warnings and half of those were in my workflow!

I wanted to look at the code for my workflow, so I opened it up in BeyondCompare and compared it to the DefaultTemplate. I had two MSBuild Activities in my build template and both instances had added the following three properties:

  • AllowUntrustedCertificate=”{x:Null}”
  • CreatePackageOnPublish=”{x:Null}”
  • DeployOnBuild=”{x:Null}”

Of course, when looking at the workflow in VS, none of these properties have any value assigned to them, so I assigned them a value one at a time. At first, my results were as I expected:

  1. Set AllowUntrustedCertificate = True for both MSBuild agents
  2. Check in changes
  3. Run the build
  4. New error: Cannot set unknown member ‘Microsoft.TeamFoundation….MsBuild.CreatePackageOnPublish’.
  5. Set CreatePackageOnPublish = False for both MSBuild agents
  6. Check in changes
  7. Run the build
  8. New Error: Cannot set unknown member ‘Microsoft.TeamFoundation…MSBuild.DeployOnBuild’.
  9. Set DeployOnBuild = False for both MSBuild agents
  10.   Check in changes
  11. Run the build
  12. Back to our original error

So, everything was looking find and good, until we got our first error back. I looked inside the xaml and the properties were set correctly. So, in a desperate move, I opened the workflow back up in VS2010 and I noticed those three properties were not even in the properties window for VS2010 and I realize (well, actually I’m assuming) that the problem isn’t that the build agent is trying to assign the value of Null to these properties, but that the build agent doesn’t know what these properties are!

The Solution:

Now I decide to just remove the properties from the workflow all together. So, I remove the values for each property in VS2011, check in my changes and I get the same error. Refresh BeyondCompare and I see that the properties are still there, and set back to {x:Null}. At this point I realized that I need to just remove the properties from the code manually. So, I make the changes, hit save and go to VS2011 to check in the changes. VS prompted and then reloaded the file, but TFS says that there are no changes to check in!

So, because you are probably tired of reading this, and I’m tired of thinking about it, I’ll just give you the final solution.

  1. Make a change to the workflow in VS2011. Save the changes, but don’t check in.
  2. Manually remove all three properties from every MSBuild Activity and then save the .xaml file
  3. Let VS2011 reload the file and save it.
  4. Check in.

Next time you run the build, it should be successful — Well at least, this problem should go away!

Important Note:

Any time you save your workflow in VS2011, it’s going to add those properties back, so you’ll need to remove them manually every time.