2

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).

Kevin
  • 16,549
  • 8
  • 60
  • 74
Ziv
  • 2,369
  • 3
  • 24
  • 40

2 Answers2

2

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

bhardwajs
  • 424
  • 4
  • 6
0

Thanks @bhardwajs, your answer helped me.
You can also add TestProjectType to global properties:

set_target_properties(${target_name} PROPERTIES
VS_GLOBAL_TestProjectType "UnitTest"
VS_GLOBAL_PROJECT_TYPES "{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")
Paweł Iwaneczko
  • 853
  • 1
  • 10
  • 13