build - 如何从上次构建中获取输出目录?

标签 build vsx envdte

假设我有一个包含一个或多个项目的解决方案,并且我刚刚使用以下方法开始构建:

_dte.Solution.SolutionBuild.Build(true); // EnvDTE.DTE

如何获取刚刚构建的每个项目的输出路径?例如...

c:\MySolution\Project1\Bin\x86\Release\
c:\MySolution\Project2\Bin\Debug

最佳答案

请不要告诉我这是唯一的方法...

// dte is my wrapper; dte.Dte is EnvDte.DTE               
var ctxs = dte.Dte.Solution.SolutionBuild.ActiveConfiguration
              .SolutionContexts.OfType<SolutionContext>()
              .Where(x => x.ShouldBuild == true);
var temp = new List<string>(); // output filenames
// oh shi
foreach (var ctx in ctxs)
{
    // sorry, you'll have to OfType<Project>() on Projects (dte is my wrapper)
    // find my Project from the build context based on its name.  Vomit.
    var project = dte.Projects.First(x => x.FullName.EndsWith(ctx.ProjectName));
    // Combine the project's path (FullName == path???) with the 
    // OutputPath of the active configuration of that project
    var dir = System.IO.Path.Combine(
                        project.FullName,
                        project.ConfigurationManager.ActiveConfiguration
                        .Properties.Item("OutputPath").Value.ToString());
    // and combine it with the OutputFilename to get the assembly
    // or skip this and grab all files in the output directory
    var filename = System.IO.Path.Combine(
                        dir,
                        project.ConfigurationManager.ActiveConfiguration
                        .Properties.Item("OutputFilename").Value.ToString());
    temp.Add(filename);
}

这让我想干呕。

关于build - 如何从上次构建中获取输出目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5626303/

相关文章:

c# - Visual Studio 生成操作的当前类型 - Microsoft.VisualStudio.Shell.Interop

visual-studio - 在 CI 服务器上的 MSBuild 中构建期间从解决方案中排除项目

visual-studio - 从 VS2010 扩展中获取当前解决方案中程序集的类型信息

c# - 从代码创建新的 c# 项目文件

c# - 从 Visual Studio 扩展中的 ProjectItem 获取 Roslyn SemanticModel

visual-studio-2010 - 在 2010 年抑制 "No Source Available" Pane

visual-studio-2010 - Visual Studio 2010 DTE : How to make added DLL reference absolute and not copied

c# - 项目集合构建错误记录器

xcode - 如何通过 XCode 中的运行脚本构建阶段添加编译源?

java - 安卓工作室 : Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'