File association icon

Jan 19 at 11:08 PM
Hi, what should go in the FileAssociation Icon property? Is it the path of the icon or (as the comments tell us) is it a reference to other wix entity?

This thread suggests adding an Icon xml tag and then reference it in the FileAssociation icon property, however there is no Icon class in the WixSharp library.
Jan 20 at 11:56 AM
This is what WiX documentation says:
For an advertised ProgId, the Id of an Icon element. For a non-advertised ProgId, this is the Id of a file containing an icon resource.
I know, it's not very clear/intuitive.

By default Wix# automatically links the Icon attribute to the parent file (e.g. exe file) thus the associated icon will be extracted from the exe resources at the index IconIndex (0 by default). I am not sure if WiX consider *.ico file as an "icon resource" (as opposite to exe files). If it does then you can add the icon file as new File(new Id("app_ico"), "app.ico") with further FileAssociation.Icon = "app_ico".

Though for the advertised setups according WiX spec it needs to be an Icon class. Wix# doesn't support Icon element directly so you will need to add it to inject it in a post-action:
project.WixSourceGenerated += Compiler_WixSourceGenerated;
static void Compiler_WixSourceGenerated(XDocument document)
            .AddElement("Icon", "Id=app_ico; SourceFile=app.ico");
If you feel that direct support for Icon element is trully beneficial please log it as a feature request on