# \#lang:csharp

**URL:** https://discourse.cmake.org/tag/lang-csharp/38.md

[Latest](https://discourse.cmake.org/latest.md) · [Categories](https://discourse.cmake.org/categories.md) · [Tags](https://discourse.cmake.org/tags.md)

---

## [JUnit Results for Collections of Tests](https://discourse.cmake.org/t/junit-results-for-collections-of-tests/15845)

<div class="topic-metadata">

**Author:** [@kevinyee](https://discourse.cmake.org/u/kevinyee)\
**Replies:** 0\
**Last updated:** [September 21, 2026, 3:53pm UTC](https://discourse.cmake.org/t/junit-results-for-collections-of-tests/15845 "2026-09-21T15:53:24Z")

</div>

My use case is for dotnet test, but I think this topic could apply to any collections of tests. I’m writing a MSTest library that I register with ctest with a COMMAND dotnet test like so: add\_library(MyTestLibrary SHAR…

---

## [Unexpected/incomplete \`install\` of CSharp library/executable/NuGet](https://discourse.cmake.org/t/unexpected-incomplete-install-of-csharp-library-executable-nuget/15708)

<div class="topic-metadata">

**Author:** [@kevinyee](https://discourse.cmake.org/u/kevinyee)\
**Replies:** 0\
**Last updated:** [June 11, 2026, 4:38am UTC](https://discourse.cmake.org/t/unexpected-incomplete-install-of-csharp-library-executable-nuget/15708 "2026-06-11T04:38:56Z")

</div>

In the example below, I would expect the everything (MyExecutable.exe, CommandLine.dll, MyLibrary.dll and Newtonsoft.Json.dll) to be installed to bin (i.e. CMAKE\_INSTALL\_BINDIR). I observe the following (output pasted be…

---

## [Generator expressions in VS\_DOTNET\_REFERENCE\_refname](https://discourse.cmake.org/t/generator-expressions-in-vs-dotnet-reference-refname/15271)

<div class="topic-metadata">

**Author:** [@retif](https://discourse.cmake.org/u/retif)\
**Replies:** 1\
**Last updated:** [October 28, 2025, 8:34pm UTC](https://discourse.cmake.org/t/generator-expressions-in-vs-dotnet-reference-refname/15271 "2025-10-28T20:34:02Z")

</div>

Are generator expressions supported for the VS\_DOTNET\_REFERENCE\_refname target property? This is how I tried to use it: # the \`some\` is a C# library which needs to refer to the DLL from the target \`thing\` set\_target\_pr…

---

## [C# SDK style projects Any CPU](https://discourse.cmake.org/t/c-sdk-style-projects-any-cpu/5913)

<div class="topic-metadata">

**Author:** [@mattsnowboard](https://discourse.cmake.org/u/mattsnowboard)\
**Replies:** 6\
**Last updated:** [October 21, 2025, 10:08pm UTC](https://discourse.cmake.org/t/c-sdk-style-projects-any-cpu/5913 "2025-10-21T22:08:22Z")

</div>

I can now generate SDK style projects for my C# projects in my c++/C# program. This has enabled me to use .NET6, which is nice. But my one problem is that the sln file generated for Visual Studio forces all of the proje…

---

## [Passing complie definitions to a include\_external\_msproject target](https://discourse.cmake.org/t/passing-complie-definitions-to-a-include-external-msproject-target/15233)

<div class="topic-metadata">

**Author:** [@Tarun](https://discourse.cmake.org/u/Tarun)\
**Replies:** 0\
**Last updated:** [October 11, 2025, 8:30am UTC](https://discourse.cmake.org/t/passing-complie-definitions-to-a-include-external-msproject-target/15233 "2025-10-11T08:30:54Z")

</div>

I have an external csproj which I want build in both linux and windows alongside other regular targets(non-custom targets) that are created using cmake. The idea was to create a custom target and use dotnet 8.0 and it’s …

---

## [target\_link\_libraries doesn't work correctly with C++/CLI compiled dll](https://discourse.cmake.org/t/target-link-libraries-doesnt-work-correctly-with-c-cli-compiled-dll/6406)

<div class="topic-metadata">

**Author:** [@lo1ol](https://discourse.cmake.org/u/lo1ol)\
**Replies:** 4\
**Last updated:** [August 6, 2025, 1:41pm UTC](https://discourse.cmake.org/t/target-link-libraries-doesnt-work-correctly-with-c-cli-compiled-dll/6406 "2025-08-06T13:41:55Z")

</div>

Hi! I noticed that cmake doesn’t link C++/CLI dll correctly. The problem is that cmake tries to link static version of library too, but it doesn’t exist. I write small example to reproduce a problem: cmake\_minimum\_requ…

---

## [DEBUG\_POSTFIX (VS\_DOTNET\_TARGET\_FRAMEWORK\_VERSION vs DOTNET\_SDK)](https://discourse.cmake.org/t/debug-postfix-vs-dotnet-target-framework-version-vs-dotnet-sdk/11759)

<div class="topic-metadata">

**Author:** [@AlamoGrito](https://discourse.cmake.org/u/AlamoGrito)\
**Replies:** 1\
**Last updated:** [September 24, 2024, 10:40am UTC](https://discourse.cmake.org/t/debug-postfix-vs-dotnet-target-framework-version-vs-dotnet-sdk/11759 "2024-09-24T10:40:55Z")

</div>

I had the need to have C# code compiled to target the Microsoft .Net Framework, .Net6 or .Net8 depending on the CMake option selected. For the MS .Net Framework I’m setting the target property VS\_DOTNET\_TARGET\_FRAMEWOR…

---

## [No CMAKE\_CSharp\_COMPILER could be found](https://discourse.cmake.org/t/no-cmake-csharp-compiler-could-be-found/10808)

<div class="topic-metadata">

**Author:** [@ian.gralinski.inv](https://discourse.cmake.org/u/ian.gralinski.inv)\
**Replies:** 1\
**Last updated:** [May 7, 2024, 12:51am UTC](https://discourse.cmake.org/t/no-cmake-csharp-compiler-could-be-found/10808 "2024-05-07T00:51:07Z")

</div>

I am trying to create a Visual Studio 2022 solution that contains C# projects, but I’m seeing the failure No CMAKE\_CSharp\_COMPILER could be found. Running the configure step with --trace-redirect I can see that the C# c…

---

## [Packaging for csharp](https://discourse.cmake.org/t/packaging-for-csharp/9905)

<div class="topic-metadata">

**Author:** [@Lecris](https://discourse.cmake.org/u/Lecris)\
**Replies:** 1\
**Last updated:** [January 23, 2024, 12:59pm UTC](https://discourse.cmake.org/t/packaging-for-csharp/9905 "2024-01-23T12:59:29Z")

</div>

Does anyone have tips on how to package a CMake project for csharp? What packaging ecosystems are there for csharp? Mainly Nuget?

---

## [How to set WarningLevel for CSharp targets](https://discourse.cmake.org/t/how-to-set-warninglevel-for-csharp-targets/7005)

<div class="topic-metadata">

**Author:** [@Knitschi](https://discourse.cmake.org/u/Knitschi)\
**Replies:** 2\
**Last updated:** [December 7, 2022, 6:35am UTC](https://discourse.cmake.org/t/how-to-set-warninglevel-for-csharp-targets/7005 "2022-12-07T06:35:58Z")

</div>

Hi everybody I am currently working on transforming our hard checked-in .csproj files into CMakeLists files. I ran into the problem that I do not know how to set the warning level in this case. This is done in the .csp…

---

## [C# SDK Style Projects - Missing Cmakelists.txt](https://discourse.cmake.org/t/c-sdk-style-projects-missing-cmakelists-txt/6036)

<div class="topic-metadata">

**Author:** [@mattsnowboard](https://discourse.cmake.org/u/mattsnowboard)\
**Replies:** 2\
**Last updated:** [July 12, 2022, 8:36pm UTC](https://discourse.cmake.org/t/c-sdk-style-projects-missing-cmakelists-txt/6036 "2022-07-12T20:36:21Z")

</div>

Is there a reason that setting DOTNET\_SDK "Microsoft.NET.Sdk" causes the CMakeLists.txt file to not show up in the generate project? It is convenient simply for quickly navigating to the file and for it to get picked up …

---

## [Generating C# .NET6 Projects - Problems with DOTNET\_SDK](https://discourse.cmake.org/t/generating-c-net6-projects-problems-with-dotnet-sdk/5745)

<div class="topic-metadata">

**Author:** [@mattsnowboard](https://discourse.cmake.org/u/mattsnowboard)\
**Replies:** 2\
**Last updated:** [June 21, 2022, 3:55pm UTC](https://discourse.cmake.org/t/generating-c-net6-projects-problems-with-dotnet-sdk/5745 "2022-06-21T15:55:19Z")

</div>

I have a project with both C/C++ native code, and C# .NET code. We can currently generate C# projects in cmake which use the “old” style of csproj files and it works perfectly fine for .NET 4.8. E.g. set\_target\_propertie…

---

## [Support for \`dotnet\` CLI and ninja generator for C#](https://discourse.cmake.org/t/support-for-dotnet-cli-and-ninja-generator-for-c/4304)

<div class="topic-metadata">

**Author:** [@bhardwajs](https://discourse.cmake.org/u/bhardwajs)\
**Replies:** 21\
**Last updated:** [November 24, 2021, 1:57pm UTC](https://discourse.cmake.org/t/support-for-dotnet-cli-and-ninja-generator-for-c/4304 "2021-11-24T13:57:31Z")

</div>

CMake supports C# using VS generator with the project files in line with .Net Framework projects. .Net also has .Net Project SDKs which enables building and running the projects on multiple platforms using .Net CLI. Cur…

---

## [Setting the working directory for a C# project (MSVC)](https://discourse.cmake.org/t/setting-the-working-directory-for-a-c-project-msvc/3838)

<div class="topic-metadata">

**Author:** [@Harald\_Scheirich](https://discourse.cmake.org/u/Harald_Scheirich)\
**Replies:** 0\
**Last updated:** [July 27, 2021, 12:36pm UTC](https://discourse.cmake.org/t/setting-the-working-directory-for-a-c-project-msvc/3838 "2021-07-27T12:36:44Z")

</div>

I have a C# project created through cmake, but i can’t find a way to set the working directory for the resulting executable using VS\_DEBUGGER\_WORKING\_DIRECTORY doesn’t seem to work. Is that a bug or just not the correct …

---

## [C# source code compilation from command line (any cases, without Visual Studio)](https://discourse.cmake.org/t/c-source-code-compilation-from-command-line-any-cases-without-visual-studio/2948)

<div class="topic-metadata">

**Author:** [@Bogdan029](https://discourse.cmake.org/u/Bogdan029)\
**Replies:** 2\
**Last updated:** [March 12, 2021, 4:37pm UTC](https://discourse.cmake.org/t/c-source-code-compilation-from-command-line-any-cases-without-visual-studio/2948 "2021-03-12T16:37:33Z")

</div>

Dear Community. I have faced on the case when is needed to compile C# source code without Visual Studio usage in order to build it in DLL library and then include this package into other platforms (not only Windows-based…
