问题
I am trying to deploy a bunch of files in a directory in my MSI setup. As the files will change frequently I don't want to add the files directly but rather have a way of automatically including all files from within a directory and deploy them to a certain location.
I am using a Visual Studio Setup Project.
Anybody know how/if this is possible?
回答1:
I solved the problem by a workaround:
- Add a build action of packaging entire directory (could be filtered) to a ZIP file.
- Add a reference to an empty ZIP file to deployment project.
- Add a custom action to deployment project to extract the ZIP to destination folder.
It's simple and stable.
回答2:
Using what????
WiX? InstallShield? Visual Studio? WISE? InstallAware? MSI Factory? Some other Windows Installer tool?
- InstallShield - yes. Add a 'dynamic folder' to your setup.
- WiX - kind of. Use
heat
to generate (partial) WiX sources before calling candle/light.
回答3:
I did this in NSIS by generating part of my NSIS script in Perl and having a master script which included the dynamic script.
Short answer: it's definitely possible.
回答4:
select the folder path and pass to this method.It will create the msi file in the order in which folder hierarchy exists.
public class InstallData { public void GetWixData(string SourcePath) { try { WixEntity[] weDir = new WixEntity[0]; weDir = BuildDirInfo(SourcePath, weDir);
var project = new Project("My Product", new Dir("MyDB", weDir), new ManagedAction("MyAction"))
{
GUID = Guid.NewGuid(),
UI = WUI.WixUI_InstallDir,
Manufacturer = "xxx Inc.",
};
try
{
Compiler.BuildMsi(project, Application.StartupPath);
}
catch (Exception ex)
{
}
}
catch (Exception Ex)
{
}
}
private 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;
}
}
public class CustomActions { [CustomAction] public static ActionResult MyAction(Session session) { MessageBox.Show("Hello World!", "Embedded Managed CA"); session.Log("Begin MyAction Hello World");
return ActionResult.Success;
}
}
来源:https://stackoverflow.com/questions/2151985/dynamically-include-files-in-msi-setup