Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include file dependencies in setup project

How do you make sure files from a project get included in the application directory created by an installer?

  • Or to put it another way: How do you include file dependencies in a setup project?

I have a DLL in my VB.NET (2010) project: TwinCAT.Ads.dll [has include] that has its own dependency: TcAds.dll [has no include anywhere in my project], which is Not a .NET assembly.

I got the compiler to make sure it spits TcAds.dll into the bin output folder when compiling by adding it as an existing item to my project, then setting it's build action to "Embedded Resource" and setting it to copy always to Output Directory.

Now that I'm ready to publish, I've made a windows setup project.
Please, no suggestions to use WIX or whatever, this is what I've got to work with.

The problem is that this outcast of a DLL does not appear as a dependency and therefore doesn't get included in the installer. After install, program runs, can't find DLL, bombs out.

  • I've tried adding it as a resource to the project to no avail. (project - properties - resources)
  • Cannot set it's build action to compile (It gives error "unable to open module file...")
  • Build action "Resource" doesn't even get it included in the bin folder, let alone the installer
  • Adding it as a reference does NOT work (It gives error "A reference to ... could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.")

Surely there must be a simple way to ensure whatever file you want gets included in the install directory?

like image 851
Scott Solmer Avatar asked Nov 02 '22 12:11

Scott Solmer


1 Answers

You can add an arbitrary file to your setup project.

enter image description here

I created a setup project and added c++ ddl file to output. It has a following section in setup project file. You can easily add your dll file to your project in this way. If you need you can write post-build script to copy this file to suitable location so that setup project will find it.

"File"
        {
            "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_06335985DF0F4EF3A600861437AA6CDF"
            {
            "SourcePath" = "8:..\\Debug\\CppWin32.dll"
            "TargetName" = "8:CppWin32.dll"
            "Tag" = "8:"
            "Folder" = "8:_1E4113F2F81040508FD1CDA54F242F25"
            "Condition" = "8:"
            "Transitive" = "11:FALSE"
            "Vital" = "11:TRUE"
            "ReadOnly" = "11:FALSE"
            "Hidden" = "11:FALSE"
            "System" = "11:FALSE"
            "Permanent" = "11:FALSE"
            "SharedLegacy" = "11:FALSE"
            "PackageAs" = "3:1"
            "Register" = "3:1"
            "Exclude" = "11:FALSE"
            "IsDependency" = "11:FALSE"
            "IsolateTo" = "8:"
            }
        }

see my build output.

------ Build started: Project: ConsoleApplication1, Configuration: Debug x86 ------
  ConsoleApplication1 -> P:\denemeler\setupDeneme\Setup1\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe
------ Starting pre-build validation for project 'Setup1' ------ 
------ Pre-build validation for project 'Setup1' completed ------
------ Build started: Project: Setup1, Configuration: Debug ------
Building file 'P:\denemeler\setupDeneme\Setup1\Setup1\Debug\Setup1.msi'...
Packaging file 'CppWin32.dll'...
Packaging file 'ConsoleApplication1.exe'...
========== Build: 2 succeeded or up-to-date, 0 failed, 0 skipped ==========
like image 145
Atilla Ozgur Avatar answered Jan 01 '23 02:01

Atilla Ozgur