Reputation: 2421
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:
TestProjectType=UnitTest
as a target property:<TestProjectType>UnitTest</TestProjectType>
<ReferencePath>$(ProgramFiles)/Common Files/microsoft shared/VSTT/$(VisualStudioVersion)/UITestExtensionPackages</ReferencePath>
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).
Upvotes: 4
Views: 1483
Reputation: 929
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}")
Upvotes: 1
Reputation: 534
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
Upvotes: 5