How to get "ProjectGuid" of *.csproj

1,017 views
Skip to first unread message

taodongl

unread,
Jul 31, 2018, 4:23:14 AM7/31/18
to resharper-plugins
WPF use the _ (underscore) char to assign a shortcut key, and Winform use the & char to assign a shortcut key.
If I want to fetch shortcut key from resx files or cs files, I need check project's type (WPF or WinForm) firstly.

I know "ProjectGuid" of *.csproj can indicate type of project. 
How can I get it? or Is there other way to detect the type of project?

(R# 2018.1.3)

Thanks.

Matt Ellis

unread,
Jul 31, 2018, 9:23:47 AM7/31/18
to resharper-plugins
You can get the project guid using IProject.Guid, however, this won't give you want you need. The project guid is a unique identifier for that project, and doesn't provide any information about the type of project. There is a project type guid, and this will tell you if it's C#, VB, F#, or whatever, but again, won't help in your use case. And finally, there are what are known as "flavour" guids. These are the values that go in the ProjectTypeGuids element in the .csproj file, and are optional. There is a WPF guid ({60DC8134-EBA5-43B8-BCC9-BB4BC16C2548}) but I don't know when it's used. It is completely possible to create a C# project that uses WPF without using this type guid. And it's perfectly possible, and indeed likely, that a project will include both WPF and WinForms. In other words, I don't think you can tell, just by looking at the project details what the shortcut identifier character is.

Regards
Matt
Reply all
Reply to author
Forward
0 new messages