Search code examples
c#visual-studiomsbuildx86-64projects-and-solutions

Build project targeting for both x86 and x64 platform


In my solution, there is a class library which is an excel add-in. When I build the solution or that project, I want this project will be built firstly targeting for x86 with outputing a file named xxx.dll, and then targeting for x64 with outputing a file named xxx_x64.dll.

How should I do for this, or how could I edit the csproj file? Thanks.


Solution

  • Finally, I have solved this problem by using Shared Project in Visual Studio. What I want is two Excel Addin assemblies will be generated by building the solution, one is targeting to x86 platform or AnyCPU, the other is targeting to x64 platform.

    Here is my projects snapshot:

    enter image description here

    All the code files(*.cs) and resources(images or xml files) are moved into the Shared project, and both the other 2 projects have a reference to it.

    As to the other 2 projects, there are some differences between them, e.g. Assembly Name and Target Platform. One is XXX.dll and targeting AnyCPU, the other is XXX_64.dll and targeting x64.

    When building the solution, each of the 2 projects will issue the corresponding assembly.