# No CMAKE\_CSharp\_COMPILER could be found

**URL:** https://discourse.cmake.org/t/no-cmake-csharp-compiler-could-be-found/10808
**Category:** Usage
**Tags:** os:windows, lang:csharp
**Created:** [May 6, 2024, 6:16am UTC](https://discourse.cmake.org/t/no-cmake-csharp-compiler-could-be-found/10808 "2024-05-06T06:16:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ian.gralinski.inv](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/i/e5b9ba/32.png) [@ian.gralinski.inv](https://discourse.cmake.org/u/ian.gralinski.inv)
#### Post date: [May 6, 2024, 6:16am UTC](https://discourse.cmake.org/t/no-cmake-csharp-compiler-could-be-found/10808/1 "2024-05-06T06:16:23Z")

</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# compiler is found but fails to compile due to

```auto
C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\Roslyn\csc.exe /noconfig /nowarn:1701,1702 /fullpaths /nostdlib+ /platform:anycpu32bitpreferred /define:Platformx64;PlatformToolsetv143 /highentropyva+ /nullable:enable /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Core.dll" /debug:pdbonly /out:obj\x64\Debug\CompilerIdCSharp.exe /subsystemversion:6.00 /target:exe /warnaserror+ /utf8output /deterministic+ /langversion:7.3 /analyzerconfig:D:\INVBUILD\wombat-software\.editorconfig /analyzerconfig:D:\INVBUILD\wombat-software\src\.editorconfig CMakeCSharpCompilerId.cs "obj\x64\Debug\.NETFramework,Version=v4.7.2.AssemblyAttributes.cs" /warnaserror+:MSB3270
CSC : error CS8630: Invalid 'nullable' value: 'Enable' for C# 7.3. Please use language version '8.0' or greater.

```

I am using `cmake version 3.29.2`.

Is there a way to influence either the C# language version selection, or whether “nullable” is enabled/disabled during CSharp compiler identification?

---

<div class="post-metadata">

### Author: ![ian.gralinski.inv](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/i/e5b9ba/32.png) [@ian.gralinski.inv](https://discourse.cmake.org/u/ian.gralinski.inv)
#### Post date: [May 7, 2024, 12:51am UTC](https://discourse.cmake.org/t/no-cmake-csharp-compiler-could-be-found/10808/2 "2024-05-07T00:51:07Z")

</div>

After some further testing I found the culprit for my issue - there is a `Directory.Build.props` file in the directory above the build output directory that enables “nullable” for all projects. When CMake is performing CSharp compiler detection it appears to be picking up some of the settings from `Directory.Build.props`. I was able to avoid the issue by moving the build output directory above where `Directory.Build.props` is located.

Should CMake be protecting against inheriting settings from `Directory.Build.props` when detecting a CSharp compiler? Perhaps it can create an empty `Directory.Build.props` file next to the `.csproj` file used to compile the test program.
