Archive for July, 2010

BizTalk MsBuild Generator Tips

Introduction
 
A couple days ago I was working on creating some msbuild scripts for building my BizTalk solutions. I am not particularly knowledgeable about the way this is usually done. I checked out my friend (and fellow MVP) Michael Stephenson’s CodePlex project, the BizTalk MsBuild Generator at http://biztalkmsbuildtool.codeplex.com/. This tool is really helpful for getting something rapidly created that you can run with. There were a couple things I did to make this free tool work a little better and I wanted to share some of these tips so that others could get the most out of Michael’s great contribution to the BizTalk community.
 
Tips
 
I was working on some solutions in BizTalk 2009, SQL 2008, Windows Server 2008 R1/R2. I first started with some solutions that were building fine in VS 2008. There were a couple of minor things I had to get some of my projects to build properly. Some of these tips will seem very simple for someone with experience doing automated builds in TFS. But for someone with less experience, it can be confusing.
 
1. After going through the wizard to generate the msbuild files, the generator created a folder full of files so I tried to kick off the build with one of the .cmd files. It got errors part way through. Basically the build was having trouble finding my projects because my solution file was in a different place than it expected it to be. After a bit of inspection of the generated files, I opened up the generated .proj file. Here is what was initially under the Build target:
 
<Target=Build>
    <
CallTarget Targets=CleanUp/>
    <
CallTarget Targets=Setup/>
    <
MSBuild Projects =$(SolutionName) Properties=Configuration=$(ConfigurationName);/>
    <
CallTarget Targets=Deployment/>
    <
CallTarget Targets=Publish/>
    <
CallTarget Targets=ApplyBindings />
    <
BizTalk.BuildGenerator.Tasks.StartApplication MessageBoxConnection=$(BizTalkManagementDatabaseConnectionString) ApplicationName=$(ProductName)/>
    <
CallTarget Targets=UnitTests Condition=$(IncludeTests) />
</
Target>

 

I changed the MSBuild element’s project attribute by setting it to $(SourceCodeRootFolder)$(SolutionName) so that it could find the location of my projects. You could use a hard coded path here if the SourceCodeRootFolder value is not valid for your solution.
 
2. I rebuilded after making the change above and the build file works almost completely until it executes the last steps and fails. Some of the default assumptions of the generator are that you will want to deploy the BizTalk applications immediately and part of the same process which is common in continuous integration environments. In my environment I am not able to do this due to some deployment rules and constraints of how my BizTalk applications are being used.
 
I seemed to particularly have trouble with the following line:
 
<BizTalk.BuildGenerator.Tasks.StartApplication MessageBoxConnection =$(BizTalkManagementDatabaseConnectionString) ApplicationName=$(ProductName)/>
 

 

My troubles were because in my local development environment I do not always maintain bindings and binding configurations for some ports. You can comment this line out to avoid trying to start the BizTalk application.
 
3. I used the tool a couple times and did not have any problems generating the file. For one of my solutions I was not able to complete the wizard and I got the following error:
 
************** Exception Text **************
System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
at System.Reflection.Assembly.nLoadFile(String path, Evidence evidence)
at System.Reflection.Assembly.LoadFile(String path)
at BizTalk.BuildGenerator.BizTalkHelper.AddResourceReferences(Resource resource, ApplicationResource applicationResource)
at BizTalk.BuildGenerator.BizTalkHelper.DescribeApplication(String applicationName)
at BizTalk.BuildGenerator.UI.UserControls.ApplicationDescriptionControl.GetDescription()
at BizTalk.BuildGenerator.UI.UserControls.ApplicationDescriptionControl.MoveNext()
at BizTalk.BuildGenerator.UI.WizardForm.ChooseApplicationPage_BeforeMoveNext(Object sender, CancelEventArgs e)
at Divelements.WizardFramework.WizardPageBase.OnBeforeMoveNext(CancelEventArgs e)
at Divelements.WizardFramework.Wizard.GoNext()
at Divelements.WizardFramework.Wizard.c(Object A_0, EventArgs A_1)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
 
This error occurs because one of the assemblies for a deployed BizTalk application cannot be found. This can happen if you have deployed your BizTalk application and then ungac an assembly by hand using gacutil /u or by deleting a file from c:Windowsassembly. For one of my solutions this was a problem. It can be notoriously hard to determine which assembly reference is the problem for large complicated solutions. This problem is repeatable – I tried a couple times.
 
I decided to dig into the problem a little deeper and downloaded the source for the generator from CodePlex. I was able to implement a quick workaround for the issue that resulted in being able to run the wizard successfully as well as generate a build file that built correctly. My patch for this issue can be found here: http://cid-62e68922e47bc425.office.live.com/self.aspx/Public/Community%20Contributions/BizTalk%20BuildGeneratorPatch%20-%207-12-2010.zip I also uploaded the patch to CodePlex and you can get it on the source codepatches link on the site. The patch includes both the assembly and the single source code file I updated.
 
If you just want the built file to fix your local installation of the BizTalk MsBuild generator, just copy the BizTalk.BuildGenerator assembly to your install folder and copy it to the GAC. If you want to build it from source, do the following. Take the BizTalkHelper.cs file from the patch and copy it over the same named file in the BizTalk.BuildGenerator project. The changes were just to wrap the body of the AddResourceReference method with a try/catch. I also added a line for logging the exception informatin.
 
Conclusion
 
These tips help you to be even more productive using the BizTalk MsBuild Generator tool. I was able to get quite a few solutions ready for MsBuild very quickly so I am glad Michael released this tool.
 
Thanks,
 

, ,

3 Comments

.NET 4 WCF Certified!, Why I take Beta Exams

I just found out this week I passed a .NET 4 beta of the WCF exam. I had taken 2 of the betas for .NET 4 and was lucky to have passed one. It is a nice honor to be in the charter group for this exam. I had previously passed the .NET 3.5 WCF exam about a year ago.
 
About 5 years ago I took and passed a couple of the .NET 2 betas and it was a very fun experience. Here are a couple reasons you should take beta exams any time you have the opportunity:
  • It is one of the biggest challenges – there is basically only MSDN documentation, VS samples, and the exam outline to study from. There are usually not books, Transcenders, or specialized test taking materials available.
  • If you are ever worried about all those brain dumps out there, take the exam before any brain dumps become available. If you pass before anyone could accuse you of cheating, there is practically no way to say you do not deserve the cert.
  • You gain a credential few people can say they have for a period of time. It is a big cool factor too. 🙂
  • It really tests your test taking endurance. If you are studying for a very long test like the CISSP, a Microsoft beta will help you extend your endurance. The betas usually take about 3 hours to do.
  • You help improve the tests by providing valuable feedback on exam items, translation, and other details.
  • Often times you earn a certification voucher good for another exam.

There are not that many times you can take beta exams so if you find an opportunity, go for it!. One way to find out about them is to go to the register page on Prometric, find a Microsoft exam with 71-* in the name, and then search the web for this exam to find the free code to get the test free. I love beta exams because they are the lowest cost opportunity to earn a certification. Thanks Microsoft for offering these!

, ,

2 Comments