I'm trying to copy some files to a specific folder inside %ProgramData% but it fails with the following error:
Unhandled Exception: WixSharp.ValidationException: WixSharp.Dir.Name is set to unknown environment constant '%ProgramData%'.
2> For the list of supported constants analyze WixSharp.Compiler.EnvironmentConstantsMapping.Keys.
2> at WixSharp.ProjectValidator.Validate(Project project)
2> at WixSharp.Compiler.GenerateWixProj(Project project)
2> at WixSharp.Compiler.BuildWxs(Project project, String path, OutputType type)
2> at WixSharp.Compiler.BuildWxs(Project project, OutputType type)
2> at WixSharp.Compiler.Build(Project project, String path, OutputType type)
2> at WixSharp.Compiler.Build(Project project, OutputType type)
2> at UploadServiceInstaller.Setup.Main() in E:\Work\Doosan\Repos\Dev\Analytics\UploadServiceInstaller\Setup.cs:line 64
This is what I'm doing:
ManagedProject project =
new ManagedProject($"{CompanyName} {ProductName}",
new InstallDir($@"%ProgramFiles%\{CompanyName}\{ProductName}",
new Files(@"bin\BuildFiles\*.*",
f => f.EndsWith(".exe") ||
f.EndsWith(".config") ||
f.EndsWith(".dll"))),
new Dir($@"%ProgramData%\{CompanyName}\{ProductName}",
new WixSharp.File(@"bin\BuildFiles\Configuration\UploadService.config")));
WixSharp.Compiler.EnvironmentConstantsMapping doesn't exist.
%PpogramData% is not one of the supported WiX constants. Use the following code to list the constants that are supported:
C#
Compiler.GetMappedWixConstants(true).ForEach(Console.WriteLine);
If it is one of the newer WiX features, which is not covered by WixSharp then you can specify its name as is, without enclosing it into % character pair.
I had same issue, i figured out, that %programmdata% is C:\ProgrammData and get with Environment.SpecialFolder Enum and Programmdata is CommonApplicationData results in same path like %programmdata%. Try it with this.
Digging around in the documentation and the code I found that I can just do:
Dir programData = new Dir(
@"CommonAppDataFolder\Company\Product",
new WixSharp.File(@"path\to\some\file"));
And CommonAppDataFolder gets translated to %ProgramData%.
Most helpful comment
Digging around in the documentation and the code I found that I can just do:
And
CommonAppDataFoldergets translated to%ProgramData%.