In Visual Studio, the context menu command for adding an element in a WinForms project is different by the one showed for a WPF project. In fact, I can see "Add->Windows Form" in the first and "Add->Window" in the second. By which parameter/configuration VisualStudio can differentiate which kind of project is currently opened? My first bet was the .csproj file but I can see nothing distinctive about the project type.
在Visual Studio中,用于在WinForms项目中添加元素的上下文菜单命令与为WPF项目显示的命令不同。事实上,我可以在第一个中看到“Add-> Windows Form”,在第二个中看到“Add-> Window”。参数/配置VisualStudio可以区分当前打开哪种项目?我的第一个赌注是.csproj文件,但我看不到项目类型的任何区别。
4 个解决方案
#1
4
There is often a ProjectTypeGuids
element in the project file that allows Visual Studio to determine what project type it is. It's also stated in the solution file, referencing the project.
项目文件中通常有一个ProjectTypeGuids元素,允许Visual Studio确定它是什么项目类型。它也在解决方案文件中声明,引用该项目。
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
as an example.
举个例子。
Here's a somewhat old link to a list of project guids, but most are still valid: http://onlinecoder.blogspot.se/2009/09/visual-studio-projects-project-type.html
这是一个项目指南列表的旧链接,但大多数仍然有效:http://onlinecoder.blogspot.se/2009/09/visual-studio-projects-project-type.html
And here's a blogpost, outlining what it's all about:
这是一篇博客文章,概述了它的全部内容:
http://www.dzimchuk.net/blog/post/ProjectTypeGuids-node-in-VS-project-files.aspx
"On a regular class library project the ‘ProjectTypeGuids’ node was missing at all. It didn’t take long to find what those mysterious GUID’s are about: List of known project type Guids. So the first one says it’s a WPF project and the second one says it’s a C# project."
“在一个普通的类库项目中,'ProjectTypeGuids'节点完全没有了。没过多久就找到了那些神秘的GUID:已知项目类型Guids列表。所以第一个说它是一个WPF项目和第二个人说这是一个C#项目。“
#2
4
ProjectTypeGuids
identify the type of project that Visual Studio recognizes. It is contained in the project file and solution file. A project can belong to multiple project types such as C# and VSTO.
ProjectTypeGuids标识Visual Studio可识别的项目类型。它包含在项目文件和解决方案文件中。项目可以属于多种项目类型,例如C#和VSTO。
WPF has a GUID of {60dc8134-eba5-43b8-bcc9-bb4bc16c2548}
while WinForms has a GUID of {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
with OutputType WinExe
.
WPF的GUID为{60dc8134-eba5-43b8-bcc9-bb4bc16c2548},而WinForms的GUID为{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC},其输出类型为WinExe。
#3
1
Almost right, it's in the solution file. Search for the property ProjectTypeGuids.
几乎是正确的,它在解决方案文件中。搜索属性ProjectTypeGuids。
Here's a list of some GUID's for project types: http://www.mztools.com/articles/2008/mz2008017.aspx
以下是项目类型的一些GUID列表:http://www.mztools.com/articles/2008/mz2008017.aspx
Edit: see this post for answers as well: How do you tell the Visual Studio project type from an existing Visual Studio project
编辑:请参阅此文章以获取答案:如何从现有的Visual Studio项目中告知Visual Studio项目类型
#4
1
It is actually a GUID in the .sln
file that identifies the project type.
它实际上是.sln文件中的GUID,用于标识项目类型。
Project("{PROJECT-TYPE-GUID}") = "OurSolution.Tests.Integration", "OurSolution.Tests.Integration\OurSolution.Tests.Integration.csproj", "{04A96D9A-FF90-4FDC-9265-704CC8D496BE}"
#1
4
There is often a ProjectTypeGuids
element in the project file that allows Visual Studio to determine what project type it is. It's also stated in the solution file, referencing the project.
项目文件中通常有一个ProjectTypeGuids元素,允许Visual Studio确定它是什么项目类型。它也在解决方案文件中声明,引用该项目。
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
as an example.
举个例子。
Here's a somewhat old link to a list of project guids, but most are still valid: http://onlinecoder.blogspot.se/2009/09/visual-studio-projects-project-type.html
这是一个项目指南列表的旧链接,但大多数仍然有效:http://onlinecoder.blogspot.se/2009/09/visual-studio-projects-project-type.html
And here's a blogpost, outlining what it's all about:
这是一篇博客文章,概述了它的全部内容:
http://www.dzimchuk.net/blog/post/ProjectTypeGuids-node-in-VS-project-files.aspx
"On a regular class library project the ‘ProjectTypeGuids’ node was missing at all. It didn’t take long to find what those mysterious GUID’s are about: List of known project type Guids. So the first one says it’s a WPF project and the second one says it’s a C# project."
“在一个普通的类库项目中,'ProjectTypeGuids'节点完全没有了。没过多久就找到了那些神秘的GUID:已知项目类型Guids列表。所以第一个说它是一个WPF项目和第二个人说这是一个C#项目。“
#2
4
ProjectTypeGuids
identify the type of project that Visual Studio recognizes. It is contained in the project file and solution file. A project can belong to multiple project types such as C# and VSTO.
ProjectTypeGuids标识Visual Studio可识别的项目类型。它包含在项目文件和解决方案文件中。项目可以属于多种项目类型,例如C#和VSTO。
WPF has a GUID of {60dc8134-eba5-43b8-bcc9-bb4bc16c2548}
while WinForms has a GUID of {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
with OutputType WinExe
.
WPF的GUID为{60dc8134-eba5-43b8-bcc9-bb4bc16c2548},而WinForms的GUID为{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC},其输出类型为WinExe。
#3
1
Almost right, it's in the solution file. Search for the property ProjectTypeGuids.
几乎是正确的,它在解决方案文件中。搜索属性ProjectTypeGuids。
Here's a list of some GUID's for project types: http://www.mztools.com/articles/2008/mz2008017.aspx
以下是项目类型的一些GUID列表:http://www.mztools.com/articles/2008/mz2008017.aspx
Edit: see this post for answers as well: How do you tell the Visual Studio project type from an existing Visual Studio project
编辑:请参阅此文章以获取答案:如何从现有的Visual Studio项目中告知Visual Studio项目类型
#4
1
It is actually a GUID in the .sln
file that identifies the project type.
它实际上是.sln文件中的GUID,用于标识项目类型。
Project("{PROJECT-TYPE-GUID}") = "OurSolution.Tests.Integration", "OurSolution.Tests.Integration\OurSolution.Tests.Integration.csproj", "{04A96D9A-FF90-4FDC-9265-704CC8D496BE}"