J
Jon Pearl
Guest
Hello, I posted this question on stack overflow initially, but perhaps it would be better to ask it here.
I'm working on an extension for VS to help with interacting with items that are built with a custom build tool. However, I've been having great difficulty with grabbing information from property page from the project item.
You can imagine the scenario as follows:
On Stack overflow, I got an answer that tipped me off to the existence of VCCustomBuildTool but wasn't sure how to get the instance that relates to my project item. While I was debugging, I found that in a project's configuration, it has a list of tools and one had the type I was looking for. This led me to write the following.
var item = dte.SelectedItems.Cast<SelectedItem>().First();
VCProjectItem vcproj = (VCProjectItem)item.ProjectItem.Object;
IVCCollection configs = (IVCCollection)vcproj.project.Configurations;
VCConfiguration config = (VCConfiguration)configs.Item(item.ProjectItem.ConfigurationManager.ActiveConfiguration.ConfigurationName);
VCCustomBuildTool tool = null;
foreach (object o in config.Tools)
{
if (o is VCCustomBuildTool)
{
tool = o as VCCustomBuildTool;
break;
}
}
// tool.CommandLine ends up being empty, it looks like the object is populated with default parameters
After getting the VCCustomBuildTool instance, it looks to be completely empty or filled with default parameters of the property page. This makes me believe I have found a template object, but not the instance of the page for the current project item. Where could I find this?
Continue reading...
I'm working on an extension for VS to help with interacting with items that are built with a custom build tool. However, I've been having great difficulty with grabbing information from property page from the project item.
You can imagine the scenario as follows:
- I have a test.myfile in the solution
- It is set to be built with a custom build tool with a commandline
On Stack overflow, I got an answer that tipped me off to the existence of VCCustomBuildTool but wasn't sure how to get the instance that relates to my project item. While I was debugging, I found that in a project's configuration, it has a list of tools and one had the type I was looking for. This led me to write the following.
var item = dte.SelectedItems.Cast<SelectedItem>().First();
VCProjectItem vcproj = (VCProjectItem)item.ProjectItem.Object;
IVCCollection configs = (IVCCollection)vcproj.project.Configurations;
VCConfiguration config = (VCConfiguration)configs.Item(item.ProjectItem.ConfigurationManager.ActiveConfiguration.ConfigurationName);
VCCustomBuildTool tool = null;
foreach (object o in config.Tools)
{
if (o is VCCustomBuildTool)
{
tool = o as VCCustomBuildTool;
break;
}
}
// tool.CommandLine ends up being empty, it looks like the object is populated with default parameters
After getting the VCCustomBuildTool instance, it looks to be completely empty or filled with default parameters of the property page. This makes me believe I have found a template object, but not the instance of the page for the current project item. Where could I find this?
Continue reading...