Hi,
I have been in contact with a PM inside Microsoft and they send me
the following solution:
Once you have VCCustomBuildRule, then you can set a property as
follows:
try
{
VCCustomBuildRule vcfilebuildrule =
(VCCustomBuildRule)vcfileconfiguration.Tool; //this cast may fail if
tool is not a custom build rule tool, use try/catch
if (vcfilebuildrule.Name == "BisonParser")
vcfilebuildrule.GetType().InvokeMember("RenameExternalSymbols",
BindingFlags.PutDispProperty, null, vcfilebuildrule, new object[1] {
"ddd" });
}
catch (Exception) { ... }
Change "BisonParser" to the name of your custom build rule, and
"RenameExternalSymbols" to be the name of the property that you are
changing. Basically, in C#, you have to deal with a late binding
problem!
One other thing I got caught with. If you are trying to change a
file's build rule to use the custom build rule, then you should do the
following:
IVCCollection fileConfigurations =
(IVCCollection)vc_file.FileConfigurations;
foreach (VCFileConfiguration config in fileConfigurations)
{
VCConfiguration proj_config =
(VCConfiguration)config.ProjectConfiguration;
VCCustomBuildRule cr =
(VCCustomBuildRule)(((IVCCollection)(proj_config.Tools)).Item("rootcint_build"));
if (cr == null)
{
throw new ArgumentException("There is not
rootcint_build tool for this configuration!");
}
config.Tool = cr;
///
/// Now, grab the config (of which the Tool property
above has made a copy) and correctly set
/// its various values.
///
ConfigureLinkdefBuildOptions((VCCustomBuildRule)
config.Tool, vc_file, prj);
}
Where ConfigureLinkdefBuildOptions is what actually sets the properties
(the try/catch handler above woudl go in this routine). The key is to
use config.Tool when you call it. If you use "cr" you'll be accessing
the build rule instance for the whole project. The config.Tool property
seems to make a copy of all the configuration parameters.
I hope this helps!
Cheers,
Gordon.