Thursday, June 27, 2013

WiX Installer with custom bootstrapper

If anyone writing a custom bootstrapper for the wix installer in .net, then something might be useful. If you are using splash screen then you need to manually close it by using the following code:

First you register splashscreen inside bundle element:

<Bundle .. SplashScreenSourceFile="splash.bmp">

and then you need to close it using the following code:

public Bootstrapper(BootstrapperApplication installer)
{
   ...
   installer.Engine.CloseSplashScreen();
}

Took me a while to find as there is no documentation regarding this.

Visual Studio .NET 2012 Toolbox crash

Visual Studio .NET 2012 Toolbox Issues

If someone encounters the issue with VS crashing when adding toolbox items, especially Systems.Activities Components. The issue happens when you add a custom workflow activity to the toolbox and then decide to  update it by overwriting the original dll. After that when you open the "choose items..." dialog, the VS.NET will crash. Below is the solution to resolve this.

Looking through reflector I located the special folder where the cached elements for toolbox are saved. They are located under:

c:\Users\{User}\AppData\Roaming\Microsoft\VisualStudio\11.0 

and the file called WorkflowElement.cache. Simply delete the file and toolbox should work for you.

The error that you will get in Event Viewer:

Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentNullException
Stack:
   at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider.IsSupportedType(System.Type)
   at Microsoft.VisualStudio.Activities.ActivitiesToolboxPage.UpdateEntries()
   at Microsoft.VisualStudio.Activities.ActivitiesToolboxPage.OnActivate(System.ComponentModel.CancelEventArgs)
   at Microsoft.VisualStudio.Shell.DialogPage+DialogSubclass.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   at Microsoft.VisualStudio.PlatformUI.NativeMethods.SendMessage(IntPtr, Int32, IntPtr, IntPtr)
   at Microsoft.VisualStudio.Toolbox.ClientControlledPageHost.SendNotification(Int32)
   at Microsoft.VisualStudio.Toolbox.ClientControlledPageHost.SetActive()
   at Microsoft.VisualStudio.Toolbox.ChooseItemsDialog+<>c__DisplayClass7.<SetClientPageActiveOnIdle>b__6()
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Window.ShowHelper(System.Object)
   at System.Windows.Window.Show()
   at System.Windows.Window.ShowDialog()
   at Microsoft.Internal.VisualStudio.PlatformUI.WindowHelper.ShowModal(System.Windows.Window, IntPtr)
   at Microsoft.VisualStudio.PlatformUI.DialogWindow.ShowModal()
   at Microsoft.VisualStudio.Toolbox.ChooseItemsService.ShowChooseItemsDialog(System.Guid ByRef)
   at Microsoft.VisualStudio.Shell.Interop.IVsUIDataSource.Invoke(System.String, System.Object, System.Object ByRef)
   at Microsoft.Internal.VisualStudio.PlatformUI.DataSource.Invoke(System.String, System.Object, System.Object ByRef)
   at Microsoft.VisualStudio.PlatformUI.VsCommand.Execute(System.Object)
   at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(System.Windows.Input.ICommandSource, Boolean)
   at System.Windows.Controls.MenuItem.InvokeClickAfterRender(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   at Microsoft.VisualStudio.PlatformUI.NativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
   at Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.<PushMessageLoopOnContextMenuTrackingComponent>b__69(System.Object, Microsoft.VisualStudio.PlatformUI.OleComponentSupport.PreTranslateMessageEventArgs)
   at Microsoft.VisualStudio.PlatformUI.OleComponentSupport.OleComponent.FPreTranslateMessageCore(Microsoft.VisualStudio.OLE.Interop.MSG[])
   at Microsoft.VisualStudio.PlatformUI.OleComponentSupport.OleComponent.Microsoft.VisualStudio.OLE.Interop.IOleComponent.FPreTranslateMessage(Microsoft.VisualStudio.OLE.Interop.MSG[])
   at Microsoft.VisualStudio.OLE.Interop.IOleComponentManager.FPushMessageLoop(UInt32, UInt32, IntPtr)
   at Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.PushMessageLoopOnContextMenuTrackingComponent()

Thursday, May 30, 2013

Building and publishing azure solution in TFS 2010

The process of creating continuous integration process in azure is well described here http://www.windowsazure.com/en-us/develop/net/common-tasks/continuous-delivery/

Unfortunately there are several issues you might encounter that are not covered in above document.

On of them is related to the error message below:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Windows Azure Tools\2.0\Microsoft.WindowsAzure.targets (632): The role 'SchedulerWorkerRole' was not found in the service definition. Parameter name: roleName

The simple solution is to add "/m:1" argument to the "MSBuild Arguments" for the Build definition. So your full MSBuild Arguments field will look something like this:

/t:Publish  /p:TargetProfile=Cloud /Property:PublishDir="//testserver/Deployment/BuildTemp/" /m:1

Explanation of why it works

In our solution we have several worker roles and web roles as part of the solution. With Azure SDK 2.0 and TFS Build all files including ServiceDefinition.csdef are copied to the single output directory. By default TFS Build includes /m flag which uses multiple threads (= number of cores) to build a solution. They can result in projects built in slightly different order and overwriting of the ServiceDefinition file, setting it to use a single thread resolve this issue.

Hope this helps somebody, as I spent a day trying to troubleshoot this.