从Visual Studio C ++项目

时间:2016-02-08 22:12:03

标签: c# visual-studio makefile

我目前正在开展一个项目,以彻底改造经典" MakeItSo"用于从Visual Studio 2010解决方案生成makefile的工具。我正在更新它以使用Visual Studio 2015,但它具有不同的VCProjectEngine,其API略有不同。

我正在尝试以编程方式为每个配置提取自定义构建规则:

using Microsoft.VisualStudio.VCProjectEngine;

    /// <summary>
    /// Parses one configuration for a custom build rule.
    /// </summary>
    private void parseCustomBuildRule_Configuration(VCFileConfiguration configuration, string relativePath) {
        // We find the custom build rule for this configuration (if there is one)...
        IVCRulePropertyStorage rule = configuration.Tool as IVCRulePropertyStorage;
        if (rule == null)
            return;

        // We will store info about this rule in a CustomBuildRuleInfo_CPP object...
        CustomBuildRule ruleInfo = new CustomBuildRule();
        ruleInfo.RelativePathToFile = relativePath;

        // There is a custom build rule, so we parse it...
        ruleInfo.RuleName = rule.GetEvaluatedPropertyValue("Name");
        string commandLine = rule.GetEvaluatedPropertyValue("CommandLine");

不幸的是,rule.GetEvaluatedPropertyValue(&#34; Name&#34;)抛出一个异常,说明找不到该属性。 GetUnevaluatedPropertyValue(&#34; Name&#34;)抛出相同的错误。甚至是&#34; CommandLine&#34;属性抛出错误。

任何想法如何解决这个问题?

0 个答案:

没有答案