How to determine the project type in visual studio

2019-01-10 16:22发布

问题:

How can you determine the "type" of a project in Visual Studio?

For example, if a project is a class library, a web application project, a WinForms project, a WCF project, etc. The icons are obviously different for a lot of them, but is there anywhere where it states the project type?

回答1:

One simple trick is drag and drop project file in notepad and where you can see this kind of stuff< <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup>enter code here <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">x86</Platform> <ProductVersion>8.0.30703</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{27F8327B-239F-4125-809C-13FB6209D2E3}</ProjectGuid> <OutputType>WinExe</OutputType>enter code here <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>WpfApplication1</RootNamespace> <AssemblyName>WpfApplication1</AssemblyName> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkProfile>Client</TargetFrameworkProfile> <FileAlignment>512</FileAlignment> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <WarningLevel>4</WarningLevel> </PropertyGroup>

Compare "ProjectTypeGuid" with this Link. by changing this guids you can add wpf window to winforms project.



回答2:

Programmatically, using the EnvDTE namespace, you can investigate the Project.Kind property of the Visual Studio project.

However, if you're interested in a more detailed, the project specification file, i.e. the *.csproj, *.vbproj, among others describes the kind of the project in an XML way.



回答3:

If the .csproj file has no <ProjectTypeGuids>

As Alex McMillan has pointed out, you could not be able to find the <ProjectTypeGuids> element.

The first answer is correct, except for .dll Library Projects, Console Applications and WinForms Applications as far I know.

They contain <OutputType> (followed by: Library or Exe or WinExe)

and do not contain <ProjectTypeGuids>.



回答4:

I think if you go to the properties window of your project you will see the information following this image below.

Please look at the output type. It shows Class library. If your project shows windows application then the output is a Windows Application.