I want to get the 开发者_运维问答binary name of a C++ Project with a Visual Studio C# Addin.
I googled and found, that the the EnvDTE.Configuration.properties should have a element called "AssemblyName" but C++ projects do not seem to have this element.
Did somebody know where could I get this information inside a visual studio addin?
For VC++ projects you need to get access to the VCConfiguration
object which you should be able to get at from the EnvDTE.Project
's Object
property like:
EnvDTE.Project project = ...
VCProject vcProj = (VCProject)project.Object;
IVCCollection configs = (IVCCollection)vcProj.Configurations;
VCConfiguration config = (VCConfiguration)configs.Item(configName); // like "Debug"
At that point with the VCConfiguration
how exactly to get at the correct properties depends on your set up. You can access the the VCLinkerTool
from the Tools
property and get at the OutputFile
and other properties. Or, if you use the newer inherited property sheets you may access those 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");
In order to get the complete path of 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;
精彩评论