Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build a mixed (C++ + C#) solution with Travis CI?

I have a solution with 4 projects:

  • a C++ .lib "A"
  • a C++ .dll (based on SWIG generated wrapper) "AWrapper"
  • a C# .dll (based on SWIG generated wrapper) "ASharp"
  • a C# Unit Test project (default, yet I can port it to NUnit) "ASharpTests"

Looking at general documentation, C# Travis CI docs and C++ docs cant get how to solve such multylingual project problem.

I can create CMake project for C++ library and wraper. But what shall I do next, how to solve next problems:

  • How to compile only selected projects from VS solution?
  • How to mix multiple lenguages, what one shall write into Travis configuration (2 C++ projects, 2 C# projects, to run tests a .so build from C++ code must be at the same folder as C# tests)?
like image 268
DuckQueen Avatar asked Oct 06 '15 22:10

DuckQueen


1 Answers

CI Build Tool - MSBuild

If you are using Visual Studio to build your C++/C#/VB/other solutions, you should use MSBuild as the CI build tool. See: https://msdn.microsoft.com/en-us/library/dd393574.aspx

MSBuild may be used to build project files in Visual Studio (.csproj,.vbproj, vcxproj, and others). However, it is not recommended. Instead, MSBuild should build Visual Studio solutions (.sln) directly. The main reason is that this way the Visual Studio IDE (used by developers) and MSBuild command line (used by CI system) build a solution exactly the same way. Secondly, changing configuration will be in one and only one place when changing projects by using the Configuration Manager in IDE.

Configuration Manager

MSBuild XML script example:

<Target Name="BUILD_SOLUTION">         
    <MSBuild Projects="$(SOLUTION_NAME).sln" Properties="Configuration=Release;Platform=Win32"/>
    <MSBuild Projects="$(SOLUTION_NAME).sln" Properties="Configuration=Release;Platform=x64"/>
</Target>

Remember to Set Project Dependencies and Check Project Build Order. For examples,

  • Common libraries built before final EXE projects;
  • Unit Test projects built after corresponding production projects.

Project Dependencies

Build Order

MSBuild Properties="Configuration=x;Platform=y" maps to Configuration Manager. Remember to set all Configuration and Platform combinations:

  • Select (enable checkbox) Build for each project context if needed;
  • Deploy column is not used.
like image 155
Garland Avatar answered Oct 20 '22 16:10

Garland