How to get output catalogs from the latest build?

Let's say I have a solution with one or more projects, and I just started building using the following method:

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

How can I get exit paths for every project I just built? For example...

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

+7
source share
3 answers

Please do not tell me that this is the only way ...

 // 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 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); } 

It makes me want to correct.

+9
source

You can get to the output folders by going through the file names in the Built output group of each project in EnvDTE:

 var outputFolders = new HashSet<string>(); var builtGroup = project.ConfigurationManager.ActiveConfiguration.OutputGroups.OfType <EnvDTE.OutputGroup>().First(x => x.CanonicalName == "Built"); foreach (var strUri in ((object[])builtGroup.FileURLs).OfType<string>()) { var uri = new Uri(strUri, UriKind.Absolute); var filePath = uri.LocalPath; var folderPath = Path.GetDirectoryName(filePath); outputFolders.Add(folderPath.ToLower()); } 
+6
source

Can anyone share the complete code please?

0
source

All Articles