Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I define a C# Unit Test Project using CMake?

I'm converting some existing C# projects to be defined in CMake -- moving from the previous include_external_msproject() directive to the newer full support for C#.

But I'm not seeing how to convert projects of the Visual C# Unit Test Project type. I'm able to build them as libraries, and compile them successfully -- but Visual Studio doesn't show them as unit test projects, just as regular libraries. Most crucially, the tests aren't visible to the Test Explorer.


Things I've already tried include:

  • Adding TestProjectType=UnitTest as a target property:
    <TestProjectType>UnitTest</TestProjectType>
  • Adding a reference path, as follows, as a target property:
    <ReferencePath>$(ProgramFiles)/Common Files/microsoft shared/VSTT/$(VisualStudioVersion)/UITestExtensionPackages</ReferencePath>
  • Adding Microsoft.VisualStudio.QualityTools.UnitTestFramework as a project reference (using CMake's VS_DOTNET_REFERENCES property).

I'm using Microsoft Visual Studio Professional 2015, CMake 3.13.2, .NET Framework 4.5.2 (but I suspect the issue isn't specific to my particular version combination).

like image 503
Ziv Avatar asked Sep 10 '25 21:09

Ziv


1 Answers

Manually adding <TestProjectType>UnitTest</TestProjectType>, made my unit test project show up as unit test. Trying to figure out how to do that using cmake.

Update: the following shows the project as unittest

set_target_properties(${target_name}
PROPERTIES
VS_GLOBAL_PROJECT_TYPES "{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
)

Documentation for VS_GLOBAL_PROJECT_TYPES is here. I found this documentation for Project Guid: Visual Studio project type guids

like image 91
bhardwajs Avatar answered Sep 13 '25 09:09

bhardwajs