Visual Studio Addin - Get Name \ C ++ Project Binary Code Path?

I want to get the binary name of a C ++ project using Visual Studio C # Addin.

I googled and found that the EnvDTE.Configuration.properties parameter should have an element called "AssemblyName", but C ++ projects don't seem to have this element.

Did anyone know where I can get this information in addition to visual studio?

+4
source share
2 answers

For VC ++ projects, you need to access the VCConfiguration object, which you should get from the EnvDTE.Project Object property, for example:

 EnvDTE.Project project = ... VCProject vcProj = (VCProject)project.Object; IVCCollection configs = (IVCCollection)vcProj.Configurations; VCConfiguration config = (VCConfiguration)configs.Item(configName); // like "Debug" 

At this point with VCConfiguration exactly how to get the right properties depends on your setup. You can access the VCLinkerTool from the Tools property and go to the OutputFile and other properties. Or, if you use new inherited property sheets, you can access them through the Rules property.

 IVCCollection tools = (IVCCollection)config.Tools; VCLinkerTool linkTool = (VCLinkerTool)tools.Item("Linker Tool"); string outputFile = linkTool.OutputFile; // ------- IVCRulePropertyStorage ruleStorage = config.Rules.Item(ruleName); string outputFile = ruleStorage.GetEvaluatedPropertyValue("TargetName"); 
+3
source

To get the full path to the binary, follow the steps as @Chadwick said to get the VCConfiguration object. And then just use the following line of code:

 //returns the complete binary name including path as a string var primaryOutput = config.PrimaryOutput; 
+2
source

All Articles