How to generate Visual Studio project targeting .NET Standard

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

How to generate Visual Studio project targeting .NET Standard

Felix Krause
Hi folks,

I am trying to generate a Visual Studio C# project with CMake.
This is what I have so far:

cmake_minimum_required(VERSION 3.10)

(myProject VERSION 0.1.0 LANGUAGES CSharp)
(myLib SHARED src/file1.cs src/file2.cs src/file3.cs)

I got the framework name from a .csproj file I generated with
Visual Studio that looks like this:

<Project Sdk="Microsoft.NET.Sdk">
This is what I need in order to build the library for .NET Standard 1.4.
However, CMake generates this (among all the other stuff):
This does not seem to be valid, since Visual Studio complains that
it cannot open the project. I did not find anything in the
CMake documentation to set <TargetFramework> instead of <TargetFrameworkVersion>.

I also tried to go along with a "normal" TargetFrameworkVersion, "4.6.1".
If I do this, the generated project will target ".NET Framework 4.6.1" and I
cannot change the target framework to ".NET Standard 1.4" in Visual Studio via
the dropdown, as the option is not available. Visual Studio seems to be unable
to switch a project from .NET Framework to .NET Standard after it has been created.

Is it possible to generate a project targeting .NET Standard with CMake?




Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: