I'm trying to create an environment inside of an msi that contains several merge modules. For some strange reason though, adding an environment variable to the msi causes the following error:
Unhandled Exception: System.InvalidOperationException: Sequence contains no elementsI wrote a small program to test it. This one works just fine.
at System.Linq.Enumerable.First[TSource](IEnumerable1 source)
2 featureComponents, List`1 defaultFeatureComponents
at WixSharp.Compiler.GetTopLevelDir(XElement product)
at WixSharp.Compiler.ProcessEnvVars(Project wProject, Dictionary
, XElement product)
at WixSharp.Compiler.GenerateWixProj(Project project)
at WixSharp.Compiler.BuildWxs(Project project, String path, OutputType type)
at WixSharp.Compiler.BuildWxs(Project project, OutputType type)
at WixSharp.Compiler.Build(Project project, String path, OutputType type)
at WixSharp.Compiler.Build(Project project, OutputType type)
at WixSharp.Compiler.BuildMsi(Project project)
at WixSharp.Project.BuildMsi(String path)
at BlastZone.Program.Main(String[] args) in C:\Users\user\Documents\Visual Studio 2015\Projects\BlastZone\BlastZone
\Program.cs:line 25
static void Main(string[] args)
{
var feature = new Feature("somename", "somedescription");
var dir = new Dir(@"%ProgramFiles%\somedir",
new Merge(feature, @"D:\path\mymsm.msm"));
var project = new Project("testproject",
dir);
project.Platform = Platform.x64;
project.PreserveTempFiles = true;
project.BuildMsi();
}
However, if I do this instead:var project = new Project("testproject",
dir,
new EnvironmentVariable("foo", "bar"));
My program falls over. Any idea what's causing this, and how can I fix it?