Installing to %PersonalFileFolders%

Aug 3, 2015 at 2:20 PM
I am creating a MSI file that installs the program (ProgramFiles (x86)), data files (ProgramData), and files in %PersonalFolder% (MyDocuments\user\App folder). Everything installs ok, but I get an error:

ICE64: The directory PersonalFolder.(folderName) is in the user profile but is not listed in the RemoveFile table. I have had no luck correcting this.
Marked as answer by rrace on 8/13/2015 at 6:41 AM
Aug 4, 2015 at 7:36 AM
It is one of those annoying "ICE validations", which sometimes have no practical value whatsoever.
You can managed it by disabling ICE validation via Light.exe command line arguments. Providing the runtime behavior of your MSI is still OK.

Alternatively you can just inject "RemoveFile" XML element where MSI wants it to be.

The starting point would be to set project.PreserveTempFiles = true; and analyse the produced .wxs file. If you can see what adjustments your WiX XML requires you can make them on fly (see InjectXML sample).

.
Marked as answer by rrace on 8/13/2015 at 6:42 AM
Aug 5, 2015 at 2:23 PM

Thank you. I set this up and see the details provided in the WIX file. But still vague on how to proceed.

Are there any Samples that add a second directory? I could not find one.

I add a “%PersonalFolder%/Test” directory. I add one file to that directory.

I get two errors:

1. Component.[file name] installs to user profile. It must use a registry key under HKCU as its KeyPath, not a file.

2. The directory Personal.Folder.Test is in the user profile but is not listed in the RemoveFile table.

I can see I should add a registry entry and add Remove.

Robert Race, PE

Race Engineering Assoc

4851 Four Seasons Ct

Eagan, MN 55122

t: 612.670.7009

e: [email removed]

Marked as answer by rrace on 8/13/2015 at 6:42 AM
Aug 5, 2015 at 2:28 PM
Why don't you create a simple "Hello World" Wix# script demonstrating the problem and share it with me. This way I can see the problem by myself instead of relying on the problem description.
Marked as answer by rrace on 8/13/2015 at 6:42 AM
Aug 5, 2015 at 2:30 PM

Good Idea. I created one here to look at myself. I will clean it up and send it to you.

Robert Race, PE

Race Engineering Assoc

4851 Four Seasons Ct

Eagan, MN 55122

t: 612.670.7009

e: [email removed]

Marked as answer by rrace on 8/13/2015 at 6:42 AM
Aug 5, 2015 at 4:48 PM

Here us a simple install that shows all the errors I receive when installing another directory.

Let me know how I can compensate you for your time. This has been a great help.

Robert Race, PE

Race Engineering Assoc

4851 Four Seasons Ct

Eagan, MN 55122

t: 612.670.7009

e: [email removed]

Marked as answer by rrace on 8/13/2015 at 6:42 AM
Aug 6, 2015 at 1:42 AM
The sample didn't get attached. May be it is a good idea to share it via Dropbox or an similar?
Alternatively you can find Wix# support email here so you can just send an ordinary email with attachment.

BTW because you are posting by email (not via wiki) your signature with your employment details get published on the wiki discussion board. You may want to edit your posts.
Marked as answer by rrace on 8/13/2015 at 6:42 AM
Aug 6, 2015 at 2:22 AM

Because I had an exe file included in the ZIP, I think it was being rejected. It was even rejected through the wix# account.

https://app.box.com/s/u34z7n6r6kgmx1sd5otcayl0mxuo7fct

This BOX account should work.

Robert Race

Marked as answer by rrace on 8/13/2015 at 6:42 AM
Aug 6, 2015 at 8:12 AM
The problem is caused by that silly MSI requirement: "you must define UserProfile registry value if you install in the UserProfile folder". This nonsense is normally handled by Wix# sharp by injecting the dummy registry value for you. But.... not in your case.

Unfortunately "PersonalFolder" was not internally recognized as a UserProfile folder so Wix# failed to help you in this case. Thus I have logged the "Issue#56: %PersonalFileFolders% is not handed as a UserProfile folder" on your behalf. The fix is already committed and it will be in the next release. BUt if you don't want to wait you can download binaries from Git

Alternatively you can fix the problem manually by injecting the required "noise":
[Fact]
[Description("Discussions #642263")]
public void Should_Inject_RemoveFolder()
{
    var project = new Project("TestProject",

                    new Dir(@"%ProgramFiles%\My Company\My Product",
                        new File(@"Files\notepad.exe")),

                    new Dir(@"%CommonAppDataFolder%\Test Project",
                        new File(@"Files\TextFile.txt")),

                    new Dir(@"%PersonalFolder%\Test Project",
                        new File(@"Files\Baskets.bbd")));

    project.WixSourceGenerated += Project_WixSourceGenerated;
    string wxs = project.BuildWxs();

    var doc = XDocument.Load(wxs);
}

void Project_WixSourceGenerated(XDocument document)
{
    var dir = document.FindAll("Directory")
                        .Where(x => x.HasAttribute("Name", "Test Project") && x.Parent.HasAttribute("Name", "PersonalFolder"))
                        .First();

    var comp = dir.Element("Component");
    comp.AddElement("RemoveFolder", "On=uninstall; Id=" + dir.Attribute("Id").Value);
    comp.AddElement("RegistryValue", @"Root=HKCU; Key=Software\[Manufacturer]\[ProductName]; Type=string; Value=; KeyPath=yes");
}
Marked as answer by rrace on 8/13/2015 at 6:42 AM
Aug 6, 2015 at 12:31 PM

Thank you, that makes sense.

I injected the fix in my sample code and I seem to be missing something.

using System;

using System.Linq;

using System.Xml;

using System.Xml.Linq;

using WixSharp;

using WixSharp.CommonTasks;

//----

project.WixSourceGenerated += Project_WixSourceGenerated;

(error: an object reference is required for the non-static field, method, or property “Script.Program.Project_WixSourceGenerated (System.Xml.Linq.XDocument))

void Project_WixSourceGenerated(XDocument document)

{

var dir = document.FindAll("Directory")

.Where(x => x.HasAttribute("Name", "Test Project") && x.Parent.HasAttribute("Name", "PersonalFolder"))

.First();

var comp = dir.Element("Component");

comp.AddElement("RemoveFolder", "On=uninstall; Id=" + dir.Attribute("Id").Value);

comp.AddElement("RegistryValue", @"Root=HKCU; Key=Software\[Manufacturer]\[ProductName]; Type=string; Value=; KeyPath=yes");

}

(error: ‘System.Xml.Linq.XElement’ does not contain a definition for ‘HasAttribute’ and the best extension method overload ‘WixSharp.Extensions.HasAttribute(System.Xml.Linq.XElement, string, System.Predicate<string>)’ has some invalid arguments.)

Argument 3: cannot convert from ‘string’ to ‘System.Predicate<string>’

I looked at the binary code to download, but am not sure what to download. This fix will work if I can figure out what is missing.

Robert Race, PE

Race Engineering Assoc

4851 Four Seasons Ct

Eagan, MN 55122

t: 612.670.7009

e: [email removed]

Marked as answer by rrace on 8/13/2015 at 6:42 AM
Aug 6, 2015 at 1:05 PM
First error is due to the fact that you are using my code from UnitTest class but your code is most likely a static class/method. You need to make Project_WixSourceGenerated static.

Second error is because the code I gave you is using the latest codebase extension method HasAttribute. In your case you need to modify the code to use the older signature:
   .Where(x => x.HasAttribute("Name", v => v == "PersonalFolder"))
For the binaries you need either to clone the repository on your PC with Git client or download from the browser:
Image
Marked as answer by rrace on 8/13/2015 at 6:42 AM
Aug 6, 2015 at 1:17 PM

I am sorry, but something isn’t working. I had the static issue resolved but the

Var comp = dir.Element(“Component”);

Returns null.

Robert Race, PE

Race Engineering Assoc

4851 Four Seasons Ct

Eagan, MN 55122

t: 612.670.7009

e: [email removed]

Marked as answer by rrace on 8/13/2015 at 6:42 AM
Aug 6, 2015 at 1:39 PM
You need to start using wiki. Your mail client prevents you from sending attachments and images. It also exposes your personal information. See it for yourself: https://wixsharp.codeplex.com/discussions/642263

Anyway, you need to find the XML 'component' of that directory element, which generates the error and inject the missing elements. In the code I provided the search algorithm is designed for my Wix# project structure. In your case you may need to adjust it to match your project structure. I can only be sure in the workaround that I provided when it is applied to the test code you sent me. You can get your adjusted sample back from here.
Aug 6, 2015 at 4:53 PM

I downloaded and built the binary files. It works as it should now.

Thank you for your help. You have done a good job of creating this application.

Robert Race, PE