0

我正在尝试编写一个工具来创建一个包含来自一个 Visual Studio 2010 解决方案的所有 PDB 文件的 zip 文件。

我可以使用以下代码获取解决方案中的每个 PDB 文件路径。但是,属性值包含 Visual Studio 宏,如 $(TargetDir)、$(TargetName) 等。

EnvDTE API 中是否有将这些宏扩展为当前值的函数?

另一方面,也欢迎任何其他可以实现我最初目标的方法!

谢谢

        System.Type t = System.Type.GetTypeFromProgID("VisualStudio.DTE.10.0");
        object obj = Activator.CreateInstance(t, true);
        DTE dte = (DTE)obj;
        Solution sln = dte.Solution;
        sln.Open(args[0]);
        while (sln.IsOpen == false)
        {
            System.Threading.Thread.Sleep(100);
        }

        sln.SolutionBuild.SolutionConfigurations.Item("Release").Activate();

        foreach (EnvDTE.Project project in sln.Projects)
        {
            Console.WriteLine("Inspecting project {0}", project.Name);

            VCProject vcproj = (VCProject)project.Object;

            if (vcproj == null) // this is not a visual c++ project
                continue;

            IVCCollection cfgs = vcproj.Configurations;
            VCConfiguration cfg = cfgs.Item(1);
            VCLinkerTool tool = cfg.Tools("VCLinkerTool");
            if (tool == null) // this is not a DLL/EXE project
                continue;
            Console.WriteLine("Program database = " + tool.ProgramDatabaseFile);
        }
4

1 回答 1

1

我没有在 VS2010 上尝试过这个,但是在 VS2008 中你可以调用 VCConfiguration.Evaluate 来做到这一点。在您的示例中,它将是这样的:

string evaluatedPdbPath = cfg.Evaluate(tool.ProgramDatabaseFile);
于 2011-12-19T22:40:11.560 回答