19

I have a program that requires both x64 and x86 dlls (it figures out which ones it needs at run time), but when trying to create a setup, it complains:

File AlphaVSS.WinXP.x64.dll' targeting 'AMD64' is not compatible with th project's target platform 'x86'
File AlphaVSS.Win2003.x64.dll' targeting 'AMD64' is not compatible with th project's target platform 'x86'
File AlphaVSS.Win2008.x64.dll' targeting 'AMD64' is not compatible with th project's target platform 'x86'

How can I make my setup target both platforms like my program does?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Malfist
  • 31,179
  • 61
  • 182
  • 269

4 Answers4

11

The MSI created by the setup project (in Visual Studio) can only target one platform at a time. Your option is to either make 2 MSI's, merge them together and make a custom setup boot strapper that choose between the two. There are some 3rd party products,like Advanced Installer for example, that can do this for you.

Magnus Johansson
  • 28,010
  • 19
  • 106
  • 164
6

I ran into this too and wrote a blog post about my solution:

  • deflate the file using deflate.exe, naming it with a different extension (e.g. .x64)
  • add it to your main project as a content file
  • add a custom action project to your solution
  • add the custom action to the setup projects "Install" custom actions
  • inflate the file inside the custom actions Install method using
  • System.IO.Compression.DeflateStream (see code above)
  • do a little dance around your desk, down the hall, and past as many coworkers as you care to annoy :)

The deflate.exe file can be downloaded from its repository on google code.

Daren Thomas
  • 67,947
  • 40
  • 154
  • 200
  • 1
    This is an excellent idea, and I recently used it in a project. One complication: if your custom action deletes the compressed file after expanding it (or you extract the contents of a zip file and then delete the zip file), and your installer installs shortcuts. By default, the shortcuts are advertised, which means that when you launch them the system will check that the installation is intact and re-run the installer when it finds the compressed file is missing. You'll need to change the msi file so that shortcuts are not advertised. – Wayne Citrin Feb 09 '13 at 00:22
1

.Net has an "Any CPU" option. It's tempting to think of it as more of a "generic" option that's going to only use the lesser x86 features, but really it lets the JIT compiler on each machine pick the appropriate cpu type for that machine.

The only time you shouldn't use it is if you know you have dependencies or requirements that aren't good for one architecture or the other. For example: you know you need a lot of ram, you have a dependancy on a 32-bit native dll, or you want to pre-compile the app.

There's a danger here because you have a platform-specific dll dependancy. But you have dlls for both types and it sounds like you know how to pick the right one at runtime. So will the 'Any CPU' option work for you?

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
  • My project is set to any, however, the setup does not allow that option. A Setup Project the property TargetPlatform and I have the option of x86, x64 and Itanium. There is not an any. – Malfist Apr 15 '09 at 20:01
  • Hmm.... the setup projects include a native .exe file to bootstrap the install in case .Net is not yet present. That may be the limiting factor. – Joel Coehoorn Apr 15 '09 at 20:04
  • In that case, could you test with a 32-bit (x86) setup project that includes both sets of dlls? The setup project should still run on x64 and x86 systems, and if things work out right you might still get the x64 code where appropriate. – Joel Coehoorn Apr 15 '09 at 20:06
  • 1
    The setup won't compile targeting x86. Only targeting x64. (fails with the errors I stated in my question.) – Malfist Apr 15 '09 at 20:07
  • Hmm... you ought to be able to get it to treat those files as just 'content' rather than code somehow, but setup projects aren't something I need to play with often enough to know how. – Joel Coehoorn Apr 15 '09 at 20:12
  • I can't keep it from treating it as an assembly, even if I add it as a 'file' – Malfist Apr 15 '09 at 20:17
  • +1d. For more info around this, see http://blogs.msdn.com/rmbyers/archive/2009/06/8/anycpu-exes-are-usually-more-trouble-then-they-re-worth.aspx – Ruben Bartelink Jan 29 '10 at 09:17
  • For those still interested (so many years after this thread was posted), the link from Ruben Bartelink just above is still around (at this writing) but moved here: https://learn.microsoft.com/en-us/archive/blogs/rmbyers/anycpu-exes-are-usually-more-trouble-than-theyre-worth – Larry Jul 03 '21 at 23:53
-2
  1. Open a deployment project.
  2. In the Solution Explorer, select the deployment project.
  3. In the Properties window, select the TargetPlatform property.
  4. Choose either Itanium for an Intel Itanium 64-bit platform, or x64 for any other 64-bit platform (such as AMD64 and EM64T instruction sets).
  5. At installation time, an error will be raised and installation will be halted if the target computer is not compatible with the specified platform.
MOHAMED SAKR
  • 134
  • 1
  • 3