Skip to content

C# support

Michael Stürmer requested to merge stuermic/cmake:csharp_simple into master

This MR introduces the first working C# support.

All remaining relevant changes go to Source/cmVisualStudio10TargetGenerator.cxx.

It's mainly adding if/else/switch checks in many places and adapt the generated output to the project type (vcxproj or csproj).

There is a test CSharpOnly added which runs for all valid Visual Studio versions (10-14, sorry I don't have 15 yet).


Missing in this MR is the auto-linking between .cs, .Designer.cs, .xaml, .xaml.cs etc. files, to the can be edited with the appropriate Visual Studio editing tools. This will be added in a final MR after this.


I also renamed the target property VS_USER_PROPS_CXX to VS_USER_PROPS because it does not really make sense having the property language dependent if the target itself will always have exactly one language. VS_USER_PROPS_CXX was introduced by me in commit e3909918 which is still not released, so I believe this change is OK. Sorry for not doing it "the right way" in the first place.


Note on mixing C++ and C# projects in one solution:

In Visual Studio there is the Configuration Manager which allows changing Configuration (Debug, Release, RelWithDebInfo, ...) and Platform (Win32, x64, ...). Unfortunately there seems to be some inconsistency between C# and C++ projects, the naming of the platform is not always the same:

C++ project C# project
64bit x64 x64
32bit Win32 x86

CMake uses Win32 as $(Platform) for 32 bit builds. To avoid errors when building a .csproj file directly with msbuild.exe I enhanced the Condition="$(Configuration)|$(Platform) ..." attribute to check for platform equal to x86 as well (only for C# and 32bit). This allows the .csproj targets to be built both from Visual Studio as well as from msbuild.

Merge request reports

Loading