Friday, 24 February 2012

DotNetToscana 2012 Spring Events

In this post, I would like to announce the next events organised by my .NET community in Italy called DotNetToscana.
The next 17th March 2012 there will be the "Windows Phone 7 3D Lab". In this lab, Nicola Baldi is introducing how to develop a 3D game in XNA using the Windows Phone platform. During the lab, a simple but real game will be created step by step in order to learn all the main important aspects of creating a game. The event will be in Pisa, Italy. You can find more information on the DotNetToscana official website.

In April 19th, instead, there will be an important event in collaboration with Microsoft called Start Something! Tour – Windows 8 e Windows Phone 7.5. This day is created for people that want to create and test their applications on Windows Phone (in partnership with Nokia) and/or on Windows 8 Tablets. This is not a step by step lab, but a way to bring passionate developers together and build awesome software with the help of the Microsoft experts and the DotNetToscana stuff members. You can find more information on the DotNetToscana official website.

We have already an idea for an event in May but it is too early to say something... stay tuned :)
I am constantly giving my contribution in order to make these events a success but I am a little sad that I will not be able to participate this time. As you know, I am now living in UK and I can't always be present to all of our events. Anyway, I am very proud to be part of this growing community and I am sure that over time will become the reference point for .NET professionals in Tuscany.

ZUGJ5HE9MTMX

Wednesday, 15 February 2012

Comparing two MSI Files using SuperOrca

ZUGJ5HE9MTMX SuperOrca (from "Pantaray Research Ltd.") is a free tool that can be use to explore and manipulate MSI files.

The two features that I like the most are the following:
  • Not lock the MSI file you are working on, so you can test it with other tools or even install it while the file is still opened in SuperOrca.
  • Provide a powerful "Compare" function that will compare two MSI files
It is very easy to use.

You can find the feature in Tools | Compare MSI Files


Then you select the two files that you want compare and press "Refresh". The results are shown in the usual way using tables.

 
From the example you can see that the property ARPCONTACT is changed from "Andrea Angella." to "Angella Andrea".

This tool is very useful for learning an MSI generator tool because allow you to understand the effects of your changes.

For my example, I simply changed the "Author" property in my setup project in Visual Studio and I rebuilt the project.



Using the tool I realized that not only the "author" property is changed but also some properties in the Icon and Shortcut table. I didn't expected this behavior.




Exploring the Windows Installer

Windows Installer is a piece of technology that we all are aware of but that few of us really know well. If you work in a small company or as a freelance developer you probably don't need to learn the complexity of Microsoft Installer and you can simply do XCopy deployments to your customers.

If you work in a medium/big company, however, releasing the software for Windows using the Microsoft Installer is the norm and it is important to understand how it works.

The installation process of a product can be extremely complex and could consist of:
  • Installing software dependencies
  • Installing services (that might require stopping/restarting other services)
  • Installing/replacing files (some could be in use)
  • Supporting rollback in case of errors
  • Supporting hot fix and upgrades
  • ...
Windows Installer provide a standard way to install, maintain and uninstall software.

Here some of the features:
  • Support for atomic installation (all or nothing)
  • Support for repair (fix a broken application)
  • Ability to share files
  • Integrated into Windows
  • WMI provider to query configuration, installed products and MSI files
  • Built-in support for installing .Net assemblies into the GAC
  • Ability to install per-user or per-machine (registry keys in HKCU or HKLM)
  • Support for upgrade and fixes
  • Support to run custom code (custom actions)
The latest version of Windows Installer is Windows Installer 5.0 that is available only for Microsoft Windows 7 and Windows Server 2008 R2. This is quite limiting and for this reason is probably reasonable to use an older version like Windows Installer 3.1 that support Windows Server 2003, Windows XP, or Windows 2000 with Service Pack 3 (SP3).

More information in Windows Installer on MSDN.

There are two important components:
  • Windows Installer Package (MSI file)
  • Windows Installer Service
The MSI file represents a setup file that the user can launch in order to install an application while the Installer Service is a Windows Service that is responsible of the installation process.


There are different ways of creating installer packages and the three more important are:
In the following page if can see a feature comparison of these tools: Choosing a Windows Installer Deployment Tool

It is clear that Wix is the more flexible and powerful way for generation MSIs. The disadvantages are that is difficult to learn and the absence of a designer to customise the installer. Anyway, I don't want to talk about Wix in this post and I will simply use the Visual Studio Setup project.

It is important to notice that Microsoft intention is to drop the support of the Visual Studio Setup project in the future versions of Visual Studio:


Caution: Future versions of Visual Studio will not include the Visual Studio Installer project templates. To preserve existing customer investments in Visual Studio Installer projects, Microsoft will continue to support the Visual Studio Installer projects that shipped with Visual Studio 2010 per the product life-cycle strategy.

In order to explore the windows installer I created a simple WPF app called MyApp and a setup project. It is all so easy.







If you build the setup project, the result will be an MSI file that you can delivery to customer:


 The setup experience is something we are quite familiar:







The interesting think about MSI file is the following:
  • An MSI file is substantially a database made of tables with rows and columns.
There is a tool called Orca that can be used to explore the content of an MSI. This tool has been created by Microsoft but it is not more officially supported. An alternative is SuperOrca.
Once you installed Orca you can right click an MSI file and edit the file in Orca.


You can see the tables in the left panel and the rows in the right panel. As you can see, there is a single component (MyApp.exe) with the version 1.0.0.0


The table Property contain various properties with values. An important property is ProductCode that is a GUID that identify the product uniquely. The Windows Installer Services uses it to determine whether your product is already present on a system.


In addition there is the PackageCode that identify the individual MSI and it is used to distinguish between different builds of the same product:


If I try to run the same installer again (same ProductCode and Package code), the system recognise that the product is already installed and prompt for repairing or removing the product.


Instead, if I rebuild the setup project in Visual Studio I get an new MSI with a new PackageCode (while the ProductCode will remain the same). In that case, when I try run the installer, I get an error:


You can find the simple code in my personal repository:
The important lesson to take away are:
  • Windows Installer is the standard way to install, maintain and uninstall software on Windows.
  • Wix is the more flexible way to generate MSI files.
  • The Visual Studio Setup Project is the easiest way to generate MSI files.
  • An MSI file is a database.
  • You can explore the content of an MSI file using the tool Orca.
  • The ProductCode identify the product uniquely.
  • The PackageCode identify the individual MSI.




Tuesday, 14 February 2012

Learning the basics of Python in an evening

I decided to enroll the free two courses delivered by Udacity: Building a Search Engine and Programming a Robotic Car. There will be programming contests and the language used will be Python. I never programmed in Python before and so I decided to start learning the language.

If you already know a language like Java, C# or C++ learning Python is relatively easy.

I started to quickly read the official tutorial:
I think that it is quite good as a starting point and teach you all the basics: control flows, data structures, modules, input and output, errors and exceptions, classes and standard library.

An another interesting resource is Learning Python in 10 minutes. This collects in a single post the basic Python syntax.

After the following reading I decided to start doing a simple coding session. I decided to implement a Code Kata and in particular the Kata Four: Data Munging.

First of all, I installed the python engine:
I decided to use the version 2.7 instead of the latest 3.2. It seems that the latest is quite recent and there are lots of breaking changes and the conversation process of many libraries is still in progress.

The next step is installing the development environment. It seems that there is a unproportional list of editors out there to develop in Python. I personally love Visual Studio and the idea of a single integrated environment and for this reason I found a Python extension for Visual Studio that was perfect for me:
Ready !!!

You can create a new project in the usual way:


and start adding files in the solution explorer:


The tool has also some good intellisense that helps in writing code. Considering that Python is a dynamic language this is quite impressive.

Here few examples:






This is an extract of the code:



You can find the complete source code in my personal repository:
I think that the best way to learn Python is using it. I am looking forward to play with it during the courses.


Saturday, 4 February 2012

Democratizing Higher Education

Last year, I have been part of the first step in the upcoming revolution of education. I took an online class on "Introduction to Artificial Intelligence" and the experience has been great. I love learning and I truly believe in the importance of higher quality education at lower cost delivered through Internet everywhere at anytime.

There are already some outstanding experiments out there:
Both offer interesting lessons on a broad range of topics for free. The topics are not strictly related with computer science.

I believe that people love learning but at the same time people want to be able to add their new skills on their CV. For this reason, it is important to organise exams and give certificates. The most important thing is price: price have to be very low in order to make education available to all the people.
There is now a new exiting project that is called Udacity with exactly this purpose in mind. The classes will be free of cost and all about computer science topics (at the moment).

Classes start on 20th February 2012 but courses will be offered again starting April 16, 2012.

The most exiting thing for me is that now they have a programming environment, so you can develop and test software. This means that there will be programming problems to solve in order to pass the course.

An another upcoming project is MITx that will offer a portfolio of MIT courses through an online interactive learning platform. I am very curious to see what will happen.

We will have plenty of cool things to learn... as usual is all about prioritising and finding the time for studying.

Sebastian Thrun resigns from Stanford to Launch Udacity. I have a great respect for this man.