How does Visual Studio /mstest identify test projects?

亡梦爱人 提交于 2019-11-28 09:06:39

In the project file, there's an XML element with the name ProjectTypeGuids, that holds a few GUIDs that denote test project. Example as follows.

<Project>
  <PropertyGroup>
    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
  </PropertyGroup>
</Project>

Here's a list of known project type GUIDs for Visual Studio 2010: http://onlinecoder.blogspot.com/2009/09/visual-studio-projects-project-type.html

In the example above, it shows the project to be of type Test and Windows (C#).

In case it helps anyone I had the opposite problem - I added a project as Unit Tests mistakenly. To change the type back to a normal Class Library I just removed the ProjectTypeGuids tags mentioned in the other answers altogether, presumably VS put back the correct ones.

Padmalochan
  1. In Solution Explorer, right-click the project name and select Unload Project.
  2. Then right-click the project name again and select Edit ProjectName.csproj.
  3. Locate the ProjectTypeGuids element and following code.(If you will not find the ProjectTypeGuids element, just insert it)

    <Project> <PropertyGroup> <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB}; {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} </ProjectTypeGuids> </PropertyGroup> </Project> .

  4. Save the changes, right-click the project, and then select Reload Project.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!