XMLPreprocess Getting Started
XMLPreprocess is a simple command line utility that can be used to deploy config files to multiple environments without having to maintain multiple copies. It can be used as a custom action in your MSI to transform the files as they are being deployed to different environments.
The goal of this tool was to minimize the maintenance of multiple configuration files for deployment and I should say it neatly meets the goal. To understand it better – a single config file can be written and maintained as the source of truth, and it can be decorated with non-breaking comments that contain the instructions for the preprocessor.
Example:
<configuration>
<system.web>
<!-- ifdef ${production} -->
<!-- <compilation defaultLanguage="c#" debug="false"/> -->
<!-- else -->
<compilation defaultLanguage="c#" debug="true"/>
<!-- endif -->
</system.web>
</configuration>
Look carefully at the comments part of the above snippet. You can easily understand that we are trying to turn off the debug page compilation when in production.
Now that is about the introduction, moving on to the actuals:
First thing first: Download the XMLPreproces from CodePlex, and extract the zip.
For this example, I will be using the spreadsheet(XML Spreadsheet 2003) as the storage of the environment specific variables. However you can also store it in a normal xml file.
I am using the sample files which came along with the download. I copied the sample.config and the SettingsSpreadSheet.xml into my xmpreprocess bin folder – I just did this to make the demo simpler – You can always provide the path for processing.
My folder looks like:
Open the SettingsSpreadsheet.xml
The columns represent the different environments you are targeting, and the values in the rows of Column A are the variables you will use in the config file. While preprocessing, the values of the variables are replaced with the corresponding value stored in the environment column.
For e.g. Let us say I want to generate a config file for testing environment, then I store the variable ServiceLocation in the column A, and then I provide the corresponding value in the column of “Test” – now when preprocessed “${ServiceLocation}” in the config file will be replaced with the corresponding value in the xml file.
Open the sample.config file;
Look at the value in the comments section “${ServiceLocation}” – as mentioned above you should add this to the variable in the settings files – just add “ServiceLocation” (dollar and braces are not required in the settings file), and provide different values for different environments.
Now use this command to preprocess:
“XmlPreprocess.exe /v /q /nologo /i sample.config /x SettingsSpreadsheet.xml /e Test /o Processed.config /d test ”
Once you run the above command, it generates another config file named Processed.config and you will have the value ”testserver” instead of localhost, in the new config file.
Now think of adding this to your WIX setup, or calling the bat file with the preprocessing info as part of build scripts. This will reduce the work of maintaining different config files for different environments.
This tool is really simple to understand, and when used efficiently gets rid of maintenance problems.
Few other resources which may help:
Cheers!
Windows Azure Commercial Pricing Announced
Today Microsoft officially announced the business and partner model for the Windows Azure platform including service level agreements and support programs.
And here is the link. Also at here.
This part of the blog is really interesting:
“Windows Azure compute hours are charged only for when your application is deployed so while developing and testing your application you may want to remove the compute instances that are not being used to minimize compute hour billing”
Cheers!
LogParser 2.2 – First Look
Recently I got introduced to a tool called LogParser while working on a critical enterprise application. It is used to extract information from the log files as easily as querying a SQL database. Guys working in enterprise applications know how important is to log a particular event, and maintain it for a period of time – it contains information deemed crucial to a business. Logs help the admin guys to troubleshoot an issue on a production box as well as for developers when the debugging is not used – mostly when the app is running on the test environment. But some times it is a nightmare to even look at the logs specially if they are on flat files and trace out the information what you really need. Log files are mostly very large in size and almost impossible to find a meaningful information out of it. LogParser bridges this gap by providing a SQL like querying ability. LogParser allows user to treat log files as just another SQL table, the rows of which can be queried, and formatted as per the users choice.
LogParser helps filter the log entries matching specific criteria and to sort the resulting entries according to values of specific files. Log parser consists of three components, which are: 1) Input processor, 2) SQL query parser, and 3) Output processor. Log parser can accept any common log format and output it into one of many formats. When you are done, you can combine all your separate logs into one common format for analysis.
Ok now lets get started. First thing to do is download the LogParser 2.2, and install it on your machine where you want to process the log files. Next run the log parser from you program files to execute the samples provided here.
Look at this sample Query: logparser.exe -i:EVT -o:NAT “SELECT TimeGenerated, EventID FROM System”
And here is the output:
Now the first part of the query : –i:EVT is processed by the input processor, –o:NAT is processed by the output process and the rest is the SQL Query processed by the SQL parser. In the above SQL Query you may see the fields like TimeGenerated, EventID – to know how exactly we can get to know these fields, try commanding with a help attribute (-h).
Query example: LogParser -h -i:EVT
And here is the output:
- i:EVT , the parameter “EVT” is used to query the System Event Log.
-o:NAT, the parameter “NAT” is used to output to a readable and nicely formatted text to the Console Window.
In the select query you can also use the “where”, “order by”, and “group by” clauses to narrow down your result output.
To output to a text file use the SQL Query with “INTO”. For e.g. logparser.exe -i:EVT -o:NAT “SELECT TimeGenerated, EventID INTO C:\out.txt FROM System” You can also write the output to a CSV file – just replace .txt to .csv. You can also output to a datagrid, use –o:datagrid.
So that was little of basics, and now let us look at a scenario, where we need to query a text log file and output to another format based on certain criteria. Now the very basic question people have is - why should they use the logparser if the intention was to extract information from one file and put it to another. To answer this think of a situation, where your log file is of size 10mb or more and it is on a server located at the other side of the globe.
Look at this query which partially addresses this problem:
LogParser ” SELECT INDEX,TEXT INTO C:\out.CSV FROM \\server\app\logs\runningTrace.log WHERE TEXT LIKE ‘%@@Start%’OR TEXT LIKE ‘%@@End%’ OR TEXT LIKE ‘%TimeStamp%’ ORDER BY INDEX ASC” -i:TEXTLINE -o:CSV
The log file which is queried upon almost looks like this:
Timestamp: 7/7/2009 11:12:30 AM
Trace Msg:
MethodName : abc.HelloWorld
TraceMessage : ——————– Processing abc.HelloWorld() ——————–
***************
Some text logged here
***************
@@Start: CriticalMethod.Processing.Started at 11:12:30:5625000
*****************
Some text Logged here
*****************
@@End: CriticalMethod.Processing.Ended at 11:12:30:6875000
————————————————————————–
Now the situation was to calculate the time taken by the method for various scenarios. And this had to be noticed for a weeks time. Think of the size of the file it would have generated for a week and now going through and analyzing them would have been a real pain. The above query provides a narrow result which can be easily analyzed by just looking at it or by an application(user-written) which can be used to read this output.
The query used here is just a sample, the actual query we use is more complicated and more powerful (think of a complicated SQL query which gives a base result). I was just amazed to see this app addressing the issue of looking into the logs, and I posted this so that it should be of help to someone. Do let me know how this has helped you guys, and do share if you come across some interesting issues.
Here is the book I found on Google. Should help.
And this one too is too good. Click Here
Cheers!
Windows 7 on VMWare
I returned back from the tech-ed event with lot many TODOs, and the top most priority being exploring Windows 7. The very first thing to do was to Download Windows 7 RC and decide on the installation. Currently my machine(Toshiba m70 Laptop with Intel Centrino 1.7Ghz, 1.2Gb of Ram, Intel 915 mobile graphics and 60Gb HDD) runs a Windows XP which was pre-installed by the vendor. I never upgraded to Windows Vista, though lot many times I tried convincing myself for. After reading couple of news, articles, blogs on the problems with Vista it was too risky for me to take a call. I decided to stick to XP, as I was very comfortable and a need for an upgrade was never there. But VJ and Vic’s session on Windows 7 was an eye opener for me, and I still cant forget the statement on running Windows 7 on a 700 Mhz cpu. I thought I should really give this a try, and see what worst is kept for me, with the marriage of my old grandpa machine and the beautiful princess Windows 7.
After a series of permutation and combination in my brain (the math on risk vs beauty) I decided not to try and Install as a parallel boot, rather go with another new concept which is installing it virtually. I downloaded the VMware WorkStation, and installed it on my machine to test drive the princess in a far more secured(from the grandpa) platform. I really doubted whether VM could detect the Windows 7 and to my surprise it detected as Windows Vista. I thought to go with it and see what happens, after all it is the Vista which is underneath.
Here are the few steps which may be helpful to you guys if you want to go with VMWare.
Click on the File-> New Virtual Machine to get this screen and select Typical. Click Next
Select the Iso image(Win 7 image file) and you can see that – “Windows Vista Detected”. Now Click next
![]()
![]()
Provide the Windows Key which you would have generated before the Windows Download. Also provide the disk space as per your requriement in the following forms. Inthe virtual machine name provide windows 7 or so. Follow the rest of the instructions and click finish.
You are done from the VMware side, now it will boot your Windows 7 setups, follow the instructions until complete. And that is it! So finally i had the Windows 7 in my laptop.
A simple note: Aero Expereince was disabled for me, since I did not have the graphic driver with WDDM support, and also VMware had defaulted my graphic driver to a VMware SVGA II. So guys if this feature is a must for you, then have a check on your graphic driver. If not just be happy with the basic display and trust me it is really smooth and fast.
My experience so far is really cool, I think this will be the next long lasting OS from MS after Windows XP.
More insights coming soon
Cheers!
tech-ed 2009 (on road) – Bangalore
Most unlikely thing I want to do now – write a blog! yeah, I am not a blogger but what inspired me to write one is the event tech-ed 2009 which was organized by BDotnet and BITPro – India’s largest and probably the best .net and IT community. “Change is Constant” Yes I have decided to change. So with the start of a new era in my life here goes my first blog which I think may inspire many others and actively participate in the online community/user groups.
I am registered with BDotnet for a while now, but was less active due to my busy schedules. It was a week before the event I received an email from the group with the details of the event. It was a two day event. What inspired me in the mail was “Windows Azure – the next big thing”, “Windows 7”, “Asp.net 4.0” and “Silverlight”. Somehow the schedule of the event worked out for me, and I registered for the event immediately. I was lucky enough to get my seat booked, as the next day there wasn’t one left. I realized the crowd it attracted and as expected it was a fully packed auditorium on both the days.
On the day one the event got ignited with a key note from Ramkumar K. It was about the technologies lined up for the future and one being the nearest – Cloud Computing. I did hear about this lot many times before, but his speech kick-started my entrepreneur bug in me and drove my imaginations to the wildest possible destinations in the future – defining wild is up to your imagination. He also talked about Green IT, which is an industry initiative for a greener community. It is impossible for me to put down his speech and my imagination into this write up, so my advice would be to log on to BDotnet and download the presentation slides there – you will be amazed – Guaranteed.
Moving on to the next session which was an exciting topic “Windows 7 – Kernel Enhancements and Location Sensors (for Dev and ITPros)” driven by the duo combination(VJ and Vic). There was an on stage chemistry between the two(don’t take me wrong) there lived a common emotion of passion for technology among both. The explanation was more on the Kernel Enhancements including the introduction of sensor and location platform. There is a lot of news on the failure of Windows Vista – and here it is – the Microsoft has a new deal – the Windows 7 a better performance. I really wondered what was going behind the make of Windows 7 so much sooner to its prior version, after the session I was thoroughly convinced with the thought that went in MS brains, the reason to have a customer satisfied at every cost. Microsoft took all its customer’s feedback seriously and corrected all the major flaws which went in Windows Vista release and set the stage for their 7th major release Windows 7. And the UI as usual a big surprise from MS. There was a remarkable statement from Vic regarding the installation and successful running of Windows 7 on 700 Mhz CPUs which was not possible with Windows Vista – this was a commitment on the performance and I remembered the very old statement “640 K ought to be enough for anyone”. Vic also presented the session on “Getting started with Silverlight 3” and what I liked more about the presentation was the attitude of the speaker. There was a presentation slide running on the screen, but Vic less looked into it and was sharing his experience to the audience. I almost felt I developed a silverlight 3 application right there, trust me with Vic it is that easy!
Being a passionate developer myself session on ASP.net 4.0 by Chaitra was one among my must to attend topics, and it did keep up with my expectations. Lot of things I learnt which I am in the process of implementing and blogging as this is more a coding stuff
. Kashi talked on “Solving Integration Challenges with BizTalk” and Meena talked on “Birds of the same feather – BizTalk Server and WCF” which I knew nothing and at the end of it I knew something. Yeah I did talk a lot on this to my friends who work on Biz Talk server and I am sure I could convince them attend the next session.
There ends my first day with the largest IT genes in the City. Oh yeah last but definitely not the least – the delicious food which was provided to us on both the days and that to FREE OF COST! It said WOW, Thanks to the Sponsors of the event!
Second day the same excitement remained in me, I don’t remember a day before this when I woke up with excitement and enthusiasm. Second day started with a session on “Building custom activities in WF” by Gayathri – I am totally a new guy in this topic but I did follow a bit. It was followed by another awaited session “Introduction to Microsoft Azure services platform” by Janakiram and Niraj Bhatt – I don’t have words to fit in here to express my excitement on this topic and probably the only reason why I am so excited about this are the speakers of this session. I understood the underlying fact about the cloud computing, and how a developer needs to prepare himself for the next big thing – as i call it all the time. I will be writing more on this session, watch for my next blog to come. Another thing I recalled at the last slide when Janakiram showed his blog web address- “Hey – this is the same guy who’s blog I would have read a lot many times.” – I was excited to see him there, I felt the world is such a small place to live in, we knew people so very well but hardly have met them. Thanks to the organizers.
And there was Vic again, with his “Keynote on Infragistics“. Everytime he is on stage I could hear lot many talks from the audience. His presentation on Infragisitcs tools was pretty awesome. He explained how closely the company works with Microsoft, and how successful they are in the market. I still remember the days and nights we spent on making a UI look perfect on all the browsers on various OS. These guys have already mastered the art, I think there will be a complete elimination of Presentation patterns and the architects will simply prefer the use of these tools, as it saves time and the client is always impressed.
Session on “Beyond Relational SQL Server 2008: Managing unstructured and semi structured Data” by Praveen Srivatsa was a very helpful topic to me, as this was something very similar to what we were trying to implement in our office. His session on “Virtualization 360 – Technical Overview” was another hot topic which kicked me off from my seat. Praveen is a great speaker, there was lot of maturity on his talk and his experience did the trick. Probably I would have never learnt so much if i were to go through all the articles on the net.
Session on “Introduction to Microsoft Exchange Server 2010” by Mohammed Ismail was also a good to know topic for me and it was followed by “Windows Server 2008 R2 Overview” by Kalyan and Ravikanth. They had the blade servers right at the auditorium “WOW” to support their topic. The topics were well presented and I was amazed to discover an introduction of “Recycle Bin” in the Acitve Directory of Windows Server 2008 R2. Kalyan(co-founder of BITPro) is a fantastic guy and I did hear a lot of excitement for his founding in his words.
And Yes it had to come – the closing note. The whole team was up on stage and there showed the sigh of relief in the organizers’ face. After all it is such a big event and to make everything go right it is not easy. They really deserve a great applause.
Oh ya something very important – they were giving Windows 7 and Windows Server 2008 R2 DVDs, though I managed to get a copy of Windows Server 2008 R2, Windows 7 was fast finishing it never reached me
. That was the only sad part, but nevertheless it was a great event.
“Hey Organizers – You guys rock. Looking forward to meeting you guys again with a bigger bang!”.
Google Profile