[CMake] How to generate Visual Studio project targeting .NET Standard
Felix Krause
flyx at flyx.org
Thu Sep 20 06:58:38 EDT 2018
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)
project(myProject VERSION 0.1.0LANGUAGES CSharp)
add_library(myLib SHARED src/file1.cs src/file2.cs src/file3.cs)
set_property(TARGET myLib PROPERTY
VS_DOTNET_TARGET_FRAMEWORK_VERSION "netstandard1.4")|
||||I got the framework name from a .csproj file I generated with
Visual Studio that looks like this:
|<ProjectSdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>netstandard1.4</TargetFramework></PropertyGroup></Project>|
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):
|<TargetFrameworkVersion>netstandard1.4</TargetFrameworkVersion> |
||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?
Thanks,
Felix
||
||
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180920/188a6644/attachment.html>
More information about the CMake
mailing list