Giter VIP home page Giter VIP logo

Comments (4)

oleg-shilo avatar oleg-shilo commented on August 27, 2024

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"));
    }
}

from wixsharp.

jhudler avatar jhudler commented on August 27, 2024

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.

from wixsharp.

oleg-shilo avatar oleg-shilo commented on August 27, 2024

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}),

from wixsharp.

jhudler avatar jhudler commented on August 27, 2024

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!

from wixsharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.