Project GUID

 

How can i access the guid of the projects that are open in my solution. The guid i am on about are the ones that are in eth csproj (or
  • Hello,

     

    That snippet can be used for your custom project:

     

    Code Snippet

     

    private 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:13
    I 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.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值