0

I need to build some application in two configurations: x86 and x64 (each config has reference on some dll, which is in 32 and 64 bit versions). I want to build in some time(one build) and as result i want to have two folders,i.e.: 1) sln_dir/x86/ 2) sln_dir/x64/

Also x86 contains 32 bit dll and x64 contains 64 bit dll. Is it possible?And if it is possible how? Thanks!

IComparable
  • 71
  • 1
  • 1
  • 10

2 Answers2

1

Well, I'd add new project configurations, and set the build type for each configuration, along with the output directory. So you might have "Debug x86" and "Debug x64" project configurations, with output directories of "bin\DebugX86" and "bin\DebugX64" for example.

That's a change that can even be done within Visual Studio, unlike most of the project file hacks I perpetrate :)

That won't build configurations with a single "build project" button press, but:

  • You could add a post-build step for one configuration to build the other
  • If this is only relevant when you build the Wix installer, I'd just script the building of that to first build both configurations

Another Visual Studio feature you should look at is the "Batch Build" option. Unfortunately it doesn't look like there's a way of saving a batch build to perform it multiple times easily :(

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • And it provide build for x86 and x64 per one build? – IComparable Apr 29 '14 at 08:41
  • @IComparable: I'm not sure what you mean by "per one build". Each project configuration will build either x86 or x64. If you want both outputs, build both configurations. I don't know if you can do that from a single msbuild command, but why do you need to? – Jon Skeet Apr 29 '14 at 08:42
  • I want push "Build project" and as result I want to see both outputs.I need it, because result of build will use in Wix installer(dll for each config has strond name), so it will be more comfartable to have both outputs. – IComparable Apr 29 '14 at 08:47
  • @IComparable: You could have a post-build step from one configuration to build the other configuration if necessary... why do you really need a single "build project" to build both? Do you really need to build the Wix installer every time you hit "build project"? Can you not just make whatever builds the Wix installer build both configurations? – Jon Skeet Apr 29 '14 at 08:49
  • I can make postbuild step. It is not only for wix. My project has reference on x86 or x64 dll with strong name, so i don't want to remove and add dll for each build. – IComparable Apr 29 '14 at 09:03
  • @IComparable: I don't know what you mean by "remove and add dll for each build". It sounds like there's quite a lot of context you haven't explained in the question, which makes it difficult to give you a good answer. In particular, it's not clear whether it's important to you to build both versions *within Visual Studio* or just as part of your automated build process. – Jon Skeet Apr 29 '14 at 09:04
0

You can:

1) Create 2 different projects with different target CPU architecture and build solution.

Solution 
      ProjectA x86 
      ProjectB x64 

Build solution. Both projects are pointing to the same source code files, naturally. There is no any source copy.

2) You can create external batch build with code like (example)

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" 
         "PATH TO SOLUTION" /Rebuild "CONFIG NAME"

Where

  • "PATH TO SOLUTION" is a path to your solution file
  • "CONFIG NAME" is a configuration name, like Release86 or Relese64.

    Write there code for every confifguration you need (those configuration have to be already configured in visual studio before). And just run that batch ones.

Tigran
  • 61,654
  • 8
  • 86
  • 123
  • 1
    One downside of the first approach is that any time you add a file to one project, you need to add it to the other as well. – Jon Skeet Apr 29 '14 at 08:50
  • Actually using this method you can. So you go into the build configuration menu in visual studio and set it so if visual studio triggers a debug/any CPU it specifically builds x86/64 for the respective projects. Do this for all configurations and regardless of what tfs calls for the correct output is generated – asuppa Jun 30 '22 at 21:54