-
Hello,
That snippet can be used for your custom project:
Code Snippetprivate Guid GetProjectGuid()
{
string projectGuid = GetProjectProperty(ProjectFileConstants.ProjectGuid);
return new Guid(projectGuid);
}
If you dig into base classes code, you will find that it uses Microsoft.Build.BuldEngine classes. Maybe that you are able to use them as well. But I believe that much more easier to use DTE object for that. Review this thread for the way how property can be retrieved using DTE: Retrieving Project's $(OutDir) from an VS Automation Macro. I think getting ProjectGuid property should be similar.
Hope that helps
-
CBrookes86 - Posted on 2007年9月11日 23:42:13I have dug around in the DTE object but i cannot seem to find how to get the project guid. I have iterated through the solution properties, the project properties and the project configuration properties with no success. Are there any other properties it may be stored in?
-
Craig Skibo - MSFT - Posted on 2007年9月12日 04:01:07
You will need to go into the VS SDK to get the GUID. First, given an EnvDTE.Project object, call UniqueName. The QueryService for the SVsSolution/IVsSolution service/interface. Next, call IVsSolution::GetProjectOfUniqueName which will return the IVsHierarchy. Finally, call IVsSolution::GetGuidOfProject passing in the IVsHierarchy. This will return to you the GUID in a string.
Craig
-
Thanks alot works perfectly. Dont think i would have ever figured that out myself.