Adding an embedded resource without making a local copy

  • Thread starter Thread starter Wysiwyg
  • Start date Start date
W

Wysiwyg

Is there any way to add an embedded resource to a project without copying it
to the project's directory? I have shared resources and don't want each
project using the images, xml files, etc. to need to be updated with the
current copy before being built. I also don't want projects being built with
the old copy.

Thanks!

Bill
 
Wysiwyg said:
Is there any way to add an embedded resource to a project without copying it
to the project's directory? I have shared resources and don't want each
project using the images, xml files, etc. to need to be updated with the
current copy before being built. I also don't want projects being built with
the old copy.

Any reason not to have the resources in a single project? You could get
the resources from that assembly, rather than having multiple copies,
one per assembly.
 
Sorry I didn't reply sooner, my usual news server keeps missing messages so
I switched to msnews.microsoft.com and found your reply.

I'm writing a program to install an addon for a business application. The
add on is application event driven and can have several forms, menus, etc.

I have to reference an installer library from the application and write code
for it so I can't just package the install with Wise Installer, MS
Installer, etc. The install exe has to run from the application and sends
events for installation started, in progress, ending, etc. I have to
generate both an installer executable and an add-on executable which is run
by the application. The application I'm writing for requires that the
add-ons be started with executables rather than linking to a dll. The
application also requires that the installer's creator generate an add-on
registration file which contains checksums of both the installer and addon
executables.

I couldn't find a way to link files I need included in the installer exe and
have them included/embedded in the installer file that would be simpler than
creating a resources directory in the installer project, adding (and
copying) all of the files I need to that resources directory as embedded
resources, and subsequently executing a prebuild command for the installer
to copy the current files to this "resources" directory. The installer would
then extract the files from the executing assembly's manifest which start
with "installer.resources." for an example.

I'd like a way to include files on the installer's manifest or a way to link
to another project's manifest and have those resources included within the
install executable regardless of file type. If I was writing a regular
windows app I could just use the MS Installer to package the entire solution
but as it is I have to write everything myself and extract the files myself.

Thanks for any assistance!
Bill Faulk
 
I couldn't find a way to link files I need included in the installer exe and
have them included/embedded in the installer file that would be simpler than
creating a resources directory in the installer project, adding (and
copying) all of the files I need to that resources directory as embedded
resources, and subsequently executing a prebuild command for the installer
to copy the current files to this "resources" directory. The installer would
then extract the files from the executing assembly's manifest which start
with "installer.resources." for an example.

What did you try in terms of having a class library project which just
contains resources? Presumably you're adding other projects into your
installer - what's different about a class library one? I've a feeling
I'm missing something about your problem...
 
By resources I don't just mean icons and bitmaps. There xml and dll files
plus at least one exe file which need to be installed as well. The
application doesn't let me just link to a library for the addon. I can't
just call a method in a library to execute my add on. I have to install at
least one exe file that is run from the application where the addon will be
registered. I really don't see how I can include all of these resources in a
class library given the requirements of the application that executes the
installation program and runs the addon. The installation program doesn't
actually need to access any of the resources it installs; It just needs to
put them on the filesystem in the right place. I'm not going to be using
rundll32.exe. :-)

Even if all the installer was required to install was a single executable
from another project and required no other resources I would still have the
original question: How do I include this external file with my installation
without copying it to the installation project?

Thanks!
Bill Faulk
 
Wysiwyg said:
By resources I don't just mean icons and bitmaps. There xml and dll files
plus at least one exe file which need to be installed as well.

That's fine - they can all be embedded as resources in an assembly.
The application doesn't let me just link to a library for the addon. I can't
just call a method in a library to execute my add on. I have to install at
least one exe file that is run from the application where the addon will be
registered. I really don't see how I can include all of these resources in a
class library given the requirements of the application that executes the
installation program and runs the addon. The installation program doesn't
actually need to access any of the resources it installs; It just needs to
put them on the filesystem in the right place. I'm not going to be using
rundll32.exe. :-)

Even if all the installer was required to install was a single executable
from another project and required no other resources I would still have the
original question: How do I include this external file with my installation
without copying it to the installation project?

By putting it as an embedded resource in your class library assembly,
and making that part of the installation project.
 
Jon Skeet said:
By putting it as an embedded resource in your class library assembly,
and making that part of the installation project.

So how would I add an embedded resource to a class library assembly in a way
that's different than adding a file to the project and selecting "embed
resource" as it's build action? If there isn't any other way then that
doesn't gain me anything.

The output for the projects to be installed are not, and will not be, class
librarys since they must be exe files due to restrictions of the application
that will use them. While I can and do put shared resources into class
librarys adding the compiled exe output of other projects into a class
library for the installer does not make sense to me.

I was just looking for a way to embed the exe files that need to be
installed into the installation project without copying them to the actual
directory of said project. If I had to embed those exe files in a class
library then I'd be looking for a way to do so without copying those
resource files to the project of the class library.

Bill Faulk
 
Actually I found what I was originally asking for. When adding an existing
item there is a drop down next to "open" which allows you to select
"open","open with...", and "link". The link option is what I was looking
for.
 
Back
Top