我在写visual studio package
,我的要求是用户必须创建empty visual studio project C++ or C#
。我如何访问这个项目,private void MenuItemCallback(object sender, EventArgs e)
以便我可以向其中添加一些动态生成的文件。
这是我到目前为止所做的
private void MenuItemCallback(object sender, EventArgs e)
{
IVsSolution solutionService = GetService(typeof(SVsSolution)) as IVsSolution;
// get all projects in solution
IEnumHierarchies enumHierarchies = null;
Guid guid = Guid.Empty;
ErrorHandler.ThrowOnFailure(solutionService.GetProjectEnum( (uint)__VSENUMPROJFLAGS.EPF_ALLINSOLUTION,ref guid,out enumHierarchies));
//Loop all projects found
if (enumHierarchies != null)
{
// Loop projects found
IVsHierarchy[] hierarchy = new IVsHierarchy[1];
uint fetched = 0;
while (enumHierarchies.Next(1, hierarchy, out fetched) == VSConstants.S_OK && fetched == 1) {
Guid projectGuid;
ErrorHandler.ThrowOnFailure(hierarchy[0].GetGuidProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ProjectIDGuid, out projectGuid));
}
}
}