How to build mixed NET5.0 and C/C++ solutions?

819 Views Asked by At

I am transitioning my .net framework projects to NET5.0, and have finished updating code/dependencies such that it all compiles and runs within Visual Studio, but now I am having issues updating my build scripts. I previously used "msbuild" to build the solution, which would build all my projects AND my C/C++ vcxprojs within the solution file. The "msbuild" command does not work for the now NET5.0 projects so I tried to use "dotnet build" as well as "dotnet publish" to build my projects, but these do not build the C/C++ projects. So logically, I next tried to build specifically those C/C++ projects prior to the "dotnet publish"'s. I did this via "msbuild" supplying the specific .vcxproj files rather than the .sln file as the project argument, but the compilations fail due to C1083 errors referencing standard headers.

Has anyone else had success building mixed solutions containing dotnet core/net5.0 projects and C/C++ projects?

Is the approach I am attempting the correct way (build C/C++ projects first then "dotnet publish" the NET5.0 projects), if so what am I doing incorrectly to cause the issues with include resolution?

Is there a more correct way to do these builds?

[Edit]: Removed cake specific language/details, as cake really just wrapped command line build options.

1

There are 1 best solutions below

1
Nils On

This is not really a question of how to build this using Cake, but rather a question of how to build a project like this in general.

If you know how to build your project from the commandline someone can tell you how to do this in Cake. However, Cannot compile template C++/CLI (.NET Core 3.1) project via dotnet build command seems to suggest that building a setup like this is not possible.

Without having any insight in c++/cli, I would suggest you try to create separate solutions for the c++/cli part (build this using msbuild) and the net5.0 part (build this using dotnet)