Question

We have some 100+ Visual Studio C# / .net solutions, which contain an Visual Studio Installer Project (vdproj) for deployment. These are build in Visual Studio 2010.

In order to upgrade to Visual Studio 2012, we need to migrate these .vdproj projects to Wix, since vs2012 doesn't support these project types anymore.

These projects are mostly simple project, which install files to the given location. We do use a custom action during setup, to make .config files location specific (replacing tags with actual values).

What is the best way (with the least effort per project) to convert these projects to Wix?

No correct solution

OTHER TIPS

I will post my reaction here. Because of better formatting and some things I like to explain.

In your response of your comment. The answer also contains a script someone made using powershell. What you could do is create another powershell that will loop through your projects and then execute the script. But then you will only have the wxs-files, you still need to create 100+ wix projects and add the files to that project.

What you could also do is create post-build events at the project(s) you would like to install, using heat.exe. for example (might need some tweaking/change for your project)

call "C:\Program Files (x86)\WiX Toolset v3.6\bin\heat.exe" project "$(ProjectDir)$(ProjectFileName)" -directoryid INSTALLDIR -pog Content -gg -scom -sreg -sfrag -out "$(SolutionDir)Installed\$(ProjectName).Content.wxs"

Then you can link the output file to the WiX project so when ever you add files or dll it will get automaticly generated again and your files will stay in sync. All you need now is to create some sort of product.wxs template that you can use in all your wix projects.

I think the solution here would be to use a combination of PowerShell and heat.exe. You can use the above command to generate the wxs-file for your projects. But you will still have the manual labor of adding wix-projects.

Are you strictly tied to Wix?

Maybe you could switch to NSIS or Inno Setup which are free (open-source) systems.

There is Visual Studio extension for working with NSIS/Inno Setup which can handle VS Setup projects (.vdproj) and convert them - http://visualstudiogallery.msdn.microsoft.com/5e57fe9a-ae5d-4740-a1c3-7a8e278e105b.

I suggest looking at Wix#. http://www.codeproject.com/Articles/31407/Wix-WixSharp-managed-interface-for-WiX.

For C# developers needing to create a Windows Installer MSI to deploy their app, Wix# is perhaps the best replacement for the "Packaging and Deployment" project type that Microsoft removed from Visual Studio starting with VS2012. Wix is a C# front end for the WiX toolset that allows building a complete Windows Installer MSI in the C# language.

You specifically mentioned that all your installers are simple projects, which install files to a given location, with a custom action during setup, to make .config files location specific (replacing tags with actual values).

Wix# would be a good fit for this type of requirements, assuming your projects are indeed highly similar as you indicate. You would develop a good Wix# example in C# for one typical program, and then clone it 100 times (or however many) for each additional .vdproj installer you are replacing. Even better, if you have a team member who is good with T4 templating, you might be able to use that to automate the process of turning your first C# Wix# prototype installer into a template, and then use that template to auto-generate the remaining 99 .cs Wix# code files for the rest of your projects.

Below is an example of the C# code for the type of Wix# installer you are requesting. This assumes that you have written a utility named "TailorMyConfig.exe", e.g., a simple C# program that uses ConfigurationManager.AppSettings routines, and you are deploying this exe along with your app.

using System;
using System.Windows.Forms;
using System.Diagnostics;
using Microsoft.Deployment.WindowsInstaller;
using WixSharp;

class Script
{
    static public void Main(string[] args)
    {
        var project = new Project("MyProduct",
                          new Dir(@"%ProgramFiles%\My Company\My Product",
                              new File(@"Files\Bin\MyApp.exe"),
                              new File(@"Files\Bin\TailorMyConfig.exe")),
                          new ManagedAction("UpdateConfigFile"));

        project.Id = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");

        Compiler.BuildMsi(project);
    }
}

public class MyCustomAction
{
    [CustomAction]
    public static ActionResult UpdateConfigFile(Session session)
    {
        if (DialogResult.Yes == MessageBox.Show("Config file update ready to run.\n Update config file(s) now?", 
                                                "Config Tailoring Utility",
                                                MessageBoxButtons.YesNo))
        {
            Process.Start("TailorMyConfig.exe", "Run utility to tailor config file to current system");
        }
        return ActionResult.Success;
    }
}

Note that there are "better" ways to modify a config file using WiX features. For simplicity, the example above assumed a custom-written C# exe utility for modifying config files. I would suggest using WiX XML capabilities for doing this instead. You can incorporate nearly any WiX XML capabilities directly into your Wix# setup using the Wix# technique of "XML injection".

Remember, Wix# is simply a C# front end that emits WiX XML syntax. After Wix# has emitted the WiX XML (wxs file), that wxs file can easily be post-processed to insert additional WiX XML features. Then the resulting wxs file gets compiled by the WiX Toolset into an MSI.

For an example of using XML Injection to incorporate WiX XML features into a Wix# (C#)installation, look here In Wix#, how to avoid creating a physical folder on the target system, when deploying only registry entries? In that question, see my answer that uses the technique of hooking up a delegate to the "WixSourceGenerated" event.

You could then use this XML injection approach to insert some WiX XML into your installer that would accomplish the config file editing. An example of some typical WiX XML to modify config files is here: How to modify .NET config files during installation?

I realize this is a somewhat older question, but it came up in my searches, so I want to make this additional Wix# option known to other searchers. The Wix# approach has been very useful in my environment, and it allows use of the familiar C# skillset without having to jump headfirst into the full complexity of the WiX XML installer technology.

You should first, get WiX book(~500 pages), and read it very carefully. Secondly, you should experiment yourself a little. Thirdly, you should manually convert them to WiX.

Do not use converters, they are useless, in the sense that they produce garbage, especially if you have quite easy installers already.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top