Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to mark a .NET assembly to be NGen'd during install #43

Closed
jhudler opened this issue Mar 20, 2017 · 4 comments
Closed

How to mark a .NET assembly to be NGen'd during install #43

jhudler opened this issue Mar 20, 2017 · 4 comments

Comments

@jhudler
Copy link

jhudler commented Mar 20, 2017

In Wix XML it is possible to add the NetFxExtension which enables the netfx:NativeImage sub-element to be added under the element.

Wix# apparently have a predefined set of sub-elements that are allowed to put inside , so this approach seems to not be possible.

What is the usual / recommended way to NGen assemblies during install via Wix#? Any examples?

@oleg-shilo
Copy link
Owner

Sorry I somehow missed your post.
Have a look at InjectXML sample. It demonstrates how to extend Wix# with a new element by implementing IGenericEntity.

Note, currently, Wix# allows generic Entities to be added to directories only. I am marking this post as enhancement and will make the change for the next release to allow generic Entities to be added to files as well. But for now you will need to find the file element in your Process method:

You will need something similar to thie:

var project =
    new Project("MyProduct",
        new Dir(@"%ProgramFiles64Folder%\My Company\My Product",
            new NativeImage { Platform = "32bit" },
            new File(@"Files\Bin\MyApp.exe"),
...

public class NativeImage : WixEntity, IGenericEntity
{
    [WixSharp.Xml]
    new public string Id
    {
        get { return base.Id; }
        set { Id = value; }
    }

    [WixSharp.Xml]
    public string Platform;

    [WixSharp.Xml]
    public int Priority = 0;

    [WixSharp.Xml]
    public string AppBaseDirectory;

  ....

    public void Process(ProcessingContext context)
    {
        var util = WixExtension.NetFx;

        context.Project.IncludeWixExtension(util);

        //serialize itself and add to the parent component
        context.XParent
               .FindAll("File")
               .First(e => e.HasAttribute("Source", value=>value.EndsWith("MyApp.exe")))
               .Add(this.ToXElement(util, "NativeImage"));
    }
}

@jhudler
Copy link
Author

jhudler commented Apr 4, 2017

Hi Oleg,

No worries.
Thanks for the response & snippet. I'll be assuming this approach by now then.
I'm glad you considered as an enhancement. Thank you again.

@oleg-shilo
Copy link
Owner

Done in 61ed80e
Ready and waiting for release.

new Project("MyProduct",
     new Dir(@"%ProgramFiles%\MyCompany\MyProduct",
         new Files(@"Release\Bin\logger.dll",
             new NativeImage { Platform = NativeImagePlatform.x86}),

@jhudler
Copy link
Author

jhudler commented Apr 12, 2017

Great News Oleg!

I see you modified the Files class to allow an IGenericEntity as child - this will bring great flexibility from now on.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants