Discussion:
[WiX-users] Compiler extension - how to include a custom action?
Nick Ramirez
2010-07-08 17:10:37 UTC
Permalink
Hello all,

I've gotten pretty far (I think) in creating a compiler extension. So far,
my extension is a .dll that can be included in my WiX MSI project. After
including the extension, I can see my new element in Visual Studio and can
add attributes to it. When I use it, a new custom table is created in the
MSI.

I've created a .wixlib project and embedded it inside my extension. In that
.wixlib, I've defined a C# DTF custom action. It's simple. It just reads my
custom table and shows a messagebox with the values from it.

However, so far, I can't get my installer to recognize the custom action (or
anything else in the .wixlib) when I include my extension and use one of its
elements.

In my extension, I'm using this code to pull the .wixlib in:


public override TableDefinitionCollection TableDefinitions
{
get
{
if (this.tableDefinitions == null)
{
this.tableDefinitions = LoadTableDefinitionHelper(
Assembly.GetExecutingAssembly(),
"MyWixExtension.Tables.MyWixTable.xml");
}

return this.tableDefinitions;
}
}


Do I need to do anything else?

Thanks for any help!
--
View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Compiler-extension-how-to-include-a-custom-action-tp5271086p5271086.html
Sent from the wix-users mailing list archive at Nabble.com.
Nick Ramirez
2010-07-08 17:12:55 UTC
Permalink
Oops. Sorry. I posted the wrong part of the code. Here's the part that I use
to register the .wixlib:


public override Library GetLibrary(TableDefinitionCollection
tableDefinitions)
{
if (this.library == null)
{
this.library = LoadLibraryHelper(
Assembly.GetExecutingAssembly(),
"SuperWixExtension.SuperWixExtensionLibrary.wixlib",
tableDefinitions);
}

return this.library;
}

Thank,
Nick
--
View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Compiler-extension-how-to-include-a-custom-action-tp5271086p5271098.html
Sent from the wix-users mailing list archive at Nabble.com.
Neil Sleightholm
2010-07-08 18:57:07 UTC
Permalink
No an answer but have you seen this: http://wixcontrib.codeplex.com/, it
taught me quite a lot about writing an extension.

Neil

-----Original Message-----
From: Nick Ramirez [mailto:***@hotmail.com]
Sent: 08 July 2010 18:13
To: wix-***@lists.sourceforge.net
Subject: Re: [WiX-users] Compiler extension - how to include a custom
action?


Oops. Sorry. I posted the wrong part of the code. Here's the part that I
use
to register the .wixlib:


public override Library GetLibrary(TableDefinitionCollection
tableDefinitions)
{
if (this.library == null)
{
this.library = LoadLibraryHelper(
Assembly.GetExecutingAssembly(),
"SuperWixExtension.SuperWixExtensionLibrary.wixlib",
tableDefinitions);
}

return this.library;
}

Thank,
Nick
--
View this message in context:
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Compiler-e
xtension-how-to-include-a-custom-action-tp5271086p5271098.html
Sent from the wix-users mailing list archive at Nabble.com.

------------------------------------------------------------------------
------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Blair
2010-07-08 19:25:34 UTC
Permalink
Did you run the extension in the debugger and verify that it was really
returning an object (and not null)?

-----Original Message-----
From: Nick Ramirez [mailto:***@hotmail.com]
Sent: Thursday, July 08, 2010 10:13 AM
To: wix-***@lists.sourceforge.net
Subject: Re: [WiX-users] Compiler extension - how to include a custom
action?


Oops. Sorry. I posted the wrong part of the code. Here's the part that I use
to register the .wixlib:


public override Library GetLibrary(TableDefinitionCollection
tableDefinitions)
{
if (this.library == null)
{
this.library = LoadLibraryHelper(
Assembly.GetExecutingAssembly(),
"SuperWixExtension.SuperWixExtensionLibrary.wixlib",
tableDefinitions);
}

return this.library;
}

Thank,
Nick
--
View this message in context:
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Compiler-exten
sion-how-to-include-a-custom-action-tp5271086p5271098.html
Sent from the wix-users mailing list archive at Nabble.com.

----------------------------------------------------------------------------
--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Nick Ramirez
2010-07-08 21:00:32 UTC
Permalink
Thanks Blair and Neil for the help. I looked at the extension you gave a link
to, Neil, but I'm not able to see anything that they have that I don't. I'm
sure there's a piece to the puzzle I'm missing.

At the risk of sounding completely clueless, how does one debug an extension
project? It seems that the GetLibrary function's parameters are populated by
Candle. Do I debug Candle somehow? And then how do I get it to use my
extension outside of an installer project?

Thanks!
--
View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Compiler-extension-how-to-include-a-custom-action-tp5271086p5271955.html
Sent from the wix-users mailing list archive at Nabble.com.
Bob Arnson
2010-07-10 15:02:03 UTC
Permalink
Post by Nick Ramirez
At the risk of sounding completely clueless, how does one debug an extension
project? It seems that the GetLibrary function's parameters are populated by
Candle. Do I debug Candle somehow?
Sure. Set a breakpoint in your extension's methods and run Candle under
a debugger. Or use ILDasm or Reflector to verify things like resource names.
--
sig://boB
http://joyofsetup.com/
Neil Sleightholm
2010-07-08 21:27:53 UTC
Permalink
Where is your wixlib located? Is it in the root of your project?

I my extension the wixlib is in a Data folder, so the full path is
MyNamespace.Data.Filename.wixlib.
Nick Ramirez
2010-07-08 21:44:55 UTC
Permalink
Oookay. So, now it's one of those situations where it didn't work and
magically...it does! What did I do? I messed around with flags for lit.exe,
removed them, changed things back to what they were orginally...rebuilt
everything and it worked. So, same code, different result. I'm not sure. I
think I'll try everything from scratch with a new solution and see what
happens. Thanks for the help!
--
View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Compiler-extension-how-to-include-a-custom-action-tp5271086p5272081.html
Sent from the wix-users mailing list archive at Nabble.com.
dB.
2010-07-12 10:33:43 UTC
Permalink
This isn't quite as magical as it sounds. I think your problem is that you think that you're REbuilding the extension, while it does some kind of incremental build. I've seen this happen a lot, but was never able to track the root cause.

PS: you have a lot more source code in http://msiext.codeplex.com. We welcome contributors.

dB. @ dblock.org
Moscow|Geneva|Seattle|New York



-----Original Message-----
From: Nick Ramirez [mailto:***@hotmail.com]
Sent: Thursday, July 08, 2010 5:45 PM
To: wix-***@lists.sourceforge.net
Subject: Re: [WiX-users] Compiler extension - how to include a custom action?


Oookay. So, now it's one of those situations where it didn't work and
magically...it does! What did I do? I messed around with flags for lit.exe,
removed them, changed things back to what they were orginally...rebuilt
everything and it worked. So, same code, different result. I'm not sure. I
think I'll try everything from scratch with a new solution and see what
happens. Thanks for the help!
--
View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Compiler-extension-how-to-include-a-custom-action-tp5271086p5272081.html
Sent from the wix-users mailing list archive at Nabble.com.
Rob Mensching
2010-07-12 14:32:15 UTC
Permalink
There is also http://wixcontrib.codeplex.com that has a couple small
extensions. Contributions are welcome there as well.
Post by dB.
This isn't quite as magical as it sounds. I think your problem is that you
think that you're REbuilding the extension, while it does some kind of
incremental build. I've seen this happen a lot, but was never able to track
the root cause.
PS: you have a lot more source code in http://msiext.codeplex.com. We welcome contributors.
Moscow|Geneva|Seattle|New York
-----Original Message-----
Sent: Thursday, July 08, 2010 5:45 PM
Subject: Re: [WiX-users] Compiler extension - how to include a custom action?
Oookay. So, now it's one of those situations where it didn't work and
magically...it does! What did I do? I messed around with flags for lit.exe,
removed them, changed things back to what they were orginally...rebuilt
everything and it worked. So, same code, different result. I'm not sure. I
think I'll try everything from scratch with a new solution and see what
happens. Thanks for the help!
--
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Compiler-extension-how-to-include-a-custom-action-tp5271086p5272081.html
Sent from the wix-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
WiX-users mailing list
https://lists.sourceforge.net/lists/listinfo/wix-users
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
WiX-users mailing list
https://lists.sourceforge.net/lists/listinfo/wix-users
--
virtually, Rob Mensching - http://RobMensching.com LLC
Nick Ramirez
2010-07-12 21:46:38 UTC
Permalink
Thanks Rob. I'd love to contribute. Where do you need more eyes?

As for the compiler extension, I'm back to where I was. I haven't been able
to get Candle to recognize the embedded wixlib in my compiler extension.
Experimenting with several ideas, I've added the <Link> element to my build
script, thinking that might be it, but it didn't solve the problem. I have
this in my extension's csproj file now:

<ItemGroup>
<EmbeddedResource Include="..\Output\CustomExtensionLibrary.wixlib">
<Link>Library\CustomExtensionLibrary.wixlib</Link>
</EmbeddedResource>
</ItemGroup>

If I use Reflector on my built assembly, I see that the wixlib, xsd and xml
file are embedded. I used the -bf flag on the wixlib so that it binds the
data into it. It's so strange. When I use my extension, the custom table is
added to the MSI, but nothing from the wixlib (CustomAction table, Binary
table).

I wonder if there's something I'm missing in the csproj file for the
extension? I see that the examples use "WixBuild.Common.targets". Do I need
to import this too and add extra MSBuild elements?

I'm still not quite sure how to debug Candle. Does anyone have experience
doing it?

I'm using WiX 3.0 in Visual Studio 2008. Thanks for the help everyone.
--
View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Compiler-extension-how-to-include-a-custom-action-tp5271086p5285053.html
Sent from the wix-users mailing list archive at Nabble.com.
Blair
2010-07-12 22:20:06 UTC
Permalink
When you add rows to your table, do you make a reference to one of the items
in your wixlib? That is usually needed to cause the appropriate fragments to
be included when your schema is translated into table entries.

The usual way is in your C# code use the CreateWixSimpleReferenceRow()
method on the Core property of your CompilerExtension's base object. Most of
us use the name of our CustomAction.

-----Original Message-----
From: Nick Ramirez [mailto:***@hotmail.com]
Sent: Monday, July 12, 2010 2:47 PM
To: wix-***@lists.sourceforge.net
Subject: Re: [WiX-users] Compiler extension - how to include a custom
action?


Thanks Rob. I'd love to contribute. Where do you need more eyes?

As for the compiler extension, I'm back to where I was. I haven't been able
to get Candle to recognize the embedded wixlib in my compiler extension.
Experimenting with several ideas, I've added the <Link> element to my build
script, thinking that might be it, but it didn't solve the problem. I have
this in my extension's csproj file now:

<ItemGroup>
<EmbeddedResource Include="..\Output\CustomExtensionLibrary.wixlib">
<Link>Library\CustomExtensionLibrary.wixlib</Link>
</EmbeddedResource>
</ItemGroup>

If I use Reflector on my built assembly, I see that the wixlib, xsd and xml
file are embedded. I used the -bf flag on the wixlib so that it binds the
data into it. It's so strange. When I use my extension, the custom table is
added to the MSI, but nothing from the wixlib (CustomAction table, Binary
table).

I wonder if there's something I'm missing in the csproj file for the
extension? I see that the examples use "WixBuild.Common.targets". Do I need
to import this too and add extra MSBuild elements?

I'm still not quite sure how to debug Candle. Does anyone have experience
doing it?

I'm using WiX 3.0 in Visual Studio 2008. Thanks for the help everyone.
--
View this message in context:
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Compiler-exten
sion-how-to-include-a-custom-action-tp5271086p5285053.html
Sent from the wix-users mailing list archive at Nabble.com.

----------------------------------------------------------------------------
--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Nick Ramirez
2010-07-12 22:20:55 UTC
Permalink
I've got an update. I've gotten my wixlib to show up in my MSI! The trick,
for me, was to add a Property to the Fragment in the wixlib I was embedding
and then use a PropertyRef to pull it in in my installer project. Pulling
that in pulled in all the other stuff (including custom actions) from the
wixlib (since it was all in the same fragment).

Is this normal? GetLibrary doesn't do it alone? You have to use a reference
element too?
--
View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Compiler-extension-how-to-include-a-custom-action-tp5271086p5285151.html
Sent from the wix-users mailing list archive at Nabble.com.
Blair
2010-07-12 22:38:31 UTC
Permalink
GetLibrary simply adds the library to the other compiled wix code that light
uses to link. There has to be some reference from somewhere for light to not
throw out the fragment as unreferenced. That is the reason most compiler
extensions use CreateWixSimpleReferenceRow to create references to
appropriate things in the embedded library's Fragments.

-----Original Message-----
From: Nick Ramirez [mailto:***@hotmail.com]
Sent: Monday, July 12, 2010 3:21 PM
To: wix-***@lists.sourceforge.net
Subject: Re: [WiX-users] Compiler extension - how to include a custom
action?


I've got an update. I've gotten my wixlib to show up in my MSI! The trick,
for me, was to add a Property to the Fragment in the wixlib I was embedding
and then use a PropertyRef to pull it in in my installer project. Pulling
that in pulled in all the other stuff (including custom actions) from the
wixlib (since it was all in the same fragment).

Is this normal? GetLibrary doesn't do it alone? You have to use a reference
element too?
--
View this message in context:
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Compiler-exten
sion-how-to-include-a-custom-action-tp5271086p5285151.html
Sent from the wix-users mailing list archive at Nabble.com.

----------------------------------------------------------------------------
--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Nick Ramirez
2010-07-13 04:08:41 UTC
Permalink
Ah, fantastic. That sounds like a much more elegant solution that using a
PropertyRef. Thanks Blair. So, it looks like this method is referencing a
table and row that would be created with the wixlib. Like this from the Util
extension.

core.CreateWixSimpleReferenceRow(sourceLineNumbers, "CustomAction",
"WixSchedInternetShortcuts");

I'll try that out. Thanks for the tip!
--
View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Compiler-extension-how-to-include-a-custom-action-tp5271086p5285857.html
Sent from the wix-users mailing list archive at Nabble.com.
Nick Ramirez [mailto:]=20
1970-01-01 00:00:00 UTC
Permalink
Hope this helps.

Neil

-----Original Message-----
From: Nick Ramirez [mailto:***@hotmail.com]=20
Sent: 08 July 2010 18:13
To: wix-***@lists.sourceforge.net
Subject: Re: [WiX-users] Compiler extension - how to include a custom
action?


Oops. Sorry. I posted the wrong part of the code. Here's the part that I
use
to register the .wixlib:


public override Library GetLibrary(TableDefinitionCollection
tableDefinitions)
{
if (this.library =3D=3D null)
{
this.library =3D LoadLibraryHelper(
Assembly.GetExecutingAssembly(),=20
"SuperWixExtension.SuperWixExtensionLibrary.wixlib",=20
tableDefinitions);
}

return this.library;
}

Thank,
Nick
--=20
View this message in context:
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Compiler-e
xtension-how-to-include-a-custom-action-tp5271086p5271098.html
Sent from the wix-users mailing list archive at Nabble.com.

------------------------------------------------------------------------
------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
Loading...