Monday, March 08, 2010

TFS Build error when having a ClickOnce project

We do not have Visual Studio installed on our TFS Build server and it seemed to be failing with the error
The "ResolveKeySource" task failed unexpectedlyerror MSB4018: The "ResolveKeySource" task failed unexpectedly.
error MSB4018: System.InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
error MSB4018: at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)

According to this blog post on Ed Squared this is due to the fact that the proj requires a certificate if you have a ClickOnce project whose certificate is not imported and it is trying to load up a dialog to ask for it. As the build is non interactive we get the error

Running MSBuild in the project directory which requires this certificate pops the dialog up and if the password is entered it seems to go ahead and do the build for any future requests. But for this to work for TFS the user will have to logon as the TFS Service for it to cache the certificate


Unable to create a constant value of type 'Closure type'

When working with the Entity Framework I got the following error when I was doing a filter

Unable to create a constant value of type 'Closure type'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.

and all I was only doing was a normal Where query with a cast to an int as follows

_entities.Persons.Where(it => it.EmployeeID == (int)EmployeeType.Permanent).ToList();

I decided to move the int cast to a temp variable outside the Where query as the error said that only primitive types were supported and it seemed to work