VS: CMakeLists.txt missing in SDK-style csproj
Minimal example of a .NET6.0 csproject using the SDK style project. After generating the Visual Studio SLN with cmake .. -G "Visual Studio 17 2022" -Ax64
it generates a project that does not reference the CMakeLists.txt for "project1".
/CMakeLists.txt
cmake_minimum_required(VERSION 3.23)
project(example LANGUAGES C CXX CSharp)
include(CTest)
add_subdirectory(project1)
/project1/CMakeLists.txt
add_library(project1 SHARED Program.cs)
set_target_properties(project1 PROPERTIES
DOTNET_SDK "Microsoft.NET.Sdk"
DOTNET_TARGET_FRAMEWORK "net6.0"
VS_GLOBAL_PlatformTarget ${CMAKE_VS_PLATFORM_NAME}
VS_GLOBAL_Platforms ${CMAKE_VS_PLATFORM_NAME}
VS_GLOBAL_Configurations "Debug;Release;RelWithDebInfo;MinSizeRel"
VS_GLOBAL_TreatWarningsAsErrors true)
/project1/Program.cs
// some file that exists
If instead, the /project1/CMakeLists.txt
contains this to generate .NET4.8 full framework, the CMakeLists.txt is included in the project:
add_library(project1 SHARED Program.cs)
set_target_properties(project1 PROPERTIES
DOTNET_TARGET_FRAMEWORK "net4.8"
VS_GLOBAL_PlatformTarget ${CMAKE_VS_PLATFORM_NAME}
VS_GLOBAL_Platforms ${CMAKE_VS_PLATFORM_NAME}
VS_GLOBAL_Configurations "Debug;Release;RelWithDebInfo;MinSizeRel"
VS_GLOBAL_TreatWarningsAsErrors true)
However this is not possible with newer versions of .NET which need the SDK-style csproj.
Edited by Brad King