0

my WiX Sharp program for Creating msi:

static public void BuildMsi(string FolderPath)
{
    string InstallationDirectoryPath = @"D:\Program";
    var project = new Project("MyProduct",
                      new Dir(InstallationDirectoryPath,
                          new Files(System.IO.Path.Combine(FolderPath,"**"))));

    Compiler.BuildMsi(project);
}

In this code if i pass the folder path which i want to release then it will create a msi that is working fine.

My Question is i want to pass multiple folder path so my main function looks like this but i am not able to figure out what i have to change in middle of the code

static public void BuildMsi(list<string> folderPath)

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
Raj
  • 33
  • 1
  • 1
  • 8

1 Answers1

0

You could try something like this, but the code is not perfect.. It will get the main directory with files and all sub directories with files.

static string sRootDir = @"<Path of main directory>";


static public void BuildMsi(string FolderPath)
{
    WixEntity[] weDir = new WixEntity[0];
        weDir = BuildDirInfo(sRootDir, weDir);
        var project = new Project("MyProduct", weDir);

    Compiler.BuildMsi(project);
}


static WixEntity[] BuildDirInfo(string sRootDir, WixEntity[] weDir)
        {
            DirectoryInfo RootDirInfo = new DirectoryInfo(sRootDir);
            if (RootDirInfo.Exists)
            {
                DirectoryInfo[] DirInfo = RootDirInfo.GetDirectories();
                List<string> lMainDirs = new List<string>();
                foreach (DirectoryInfo DirInfoSub in DirInfo)
                    lMainDirs.Add(DirInfoSub.FullName);
                int cnt = lMainDirs.Count;
                weDir = new WixEntity[cnt + 1];
                if (cnt == 0)
                    weDir[0] = new DirFiles(RootDirInfo.FullName + @"\*.*");
                else
                {
                    weDir[cnt] = new DirFiles(RootDirInfo.FullName + @"\*.*");
                    for (int i = 0; i < cnt; i++)
                    {
                        DirectoryInfo RootSubDirInfo = new DirectoryInfo(lMainDirs[i]);
                        if (!RootSubDirInfo.Exists)
                            continue;
                        WixEntity[] weSubDir = new WixEntity[0];
                        weSubDir = BuildDirInfo(RootSubDirInfo.FullName, weSubDir);
                        weDir[i] = new Dir(RootSubDirInfo.Name, weSubDir);
                    }
                }
            }
            return weDir;
        }
ArchAngel
  • 634
  • 7
  • 16