2

My setup consists of three separate projects:

  • MyApp - C# application. References CLibraryWrapper (includes as a git submodule)
  • CLibraryWrapper - C# class library which is a C# wrapper for native C library. Depends on CLibrary (includes it as a git submodule)
  • CLibrary - C shared library.
C# platform=AnyCPU                     C# platform=AnyCPU
+----------------+     References      +------------------------+
|     MyApp      +--------------------->    CLibraryWrapper     |
|                |                     |                        |
| MyApp.sln      |                     | CLibraryWrapper.sln    |
| MyApp.csproj   |                     | CLibraryWrapper.csproj |
|                |                     |                        |
+----------------+                     +-------+----------------+
                                               |
                                               | Depends
                                               |
                                               v
                                       C Shared Library
                                       +------------------+
                                       |     CLibrary     |
                                       |                  |
                                       | CLibrary.sln     |
                                       | CLibrary.vcxproj |
                                       |                  |
                                       +------------------+

Question #1

I should be able to build CLibraryWrapper for AnyCPU platform and that requires setting up CLibraryWrapper project in a such way that it would build CLibrary for x86 and x64 platforms. I'm loading CLibrary.dll at run-time depending on the process platform so I need both (x86 and x64) binaries to be present.

End result after CLibraryWrapper AnyCPU build should look like this:

|_bin/Debug/
  |_CLibraryWrapper.dll
  |_x86/
    |_CLibrary.dll
  |_x64/
    |_CLibrary.dll

Is there a way to achieve this in Visual Studio build configuration?

Question #2

MyApp should be able to add CLibraryWrapper as a project reference.

End result should be that MyApp builds CLibraryWrapper which in turn builds x86/CLibrary.dll and x64/CLibrary.dll. This way MyApp would be built with all it's dependencies from source code.

I've read that you can't reference solution from another solution. And solution controls build dependencies. I would really like MyApp to reference CLibraryWrapper and inherit CLibrary build configuration.

I was not able to find out how to setup my Visual Studio build configuration this way.

kestutisb
  • 261
  • 2
  • 13
  • Hi friend, please check [this issue](https://stackoverflow.com/questions/28280101/any-cpu-not-available-in-c-c-solution). Not sure if the first answer from Peter can help. (But I think you can have a try with it) – LoLance Mar 18 '19 at 05:56
  • And for the question1, as i know there has no option or setting for this situation. What if we use pre-build event to copy the output of CLibrary to bin folder of ClibraryWrapper, and then load them at run-time with relative path like [this simple](https://github.com/kevin-marshall/Managed.AnyCPU) from Kevin. – LoLance Mar 19 '19 at 06:44

0 Answers0