Is it possible to obtain a list all all the output files from a MSBuild project?
In a simple project, I could do something like
<CreateItem Include="$(OutputDir)**\*">
<Output ItemName="AllOutputs" TaskParameter="Include"/>
</CreateItem>
but my projects are part of a larger build, and all outputs go to a common location, I want to be able to exculde dlls and content that don't belong.
Any ideas?
The Microsoft Build Engine is a platform for building applications. This engine, which is also known as MSBuild, provides an XML schema for a project file that controls how the build platform processes and builds software.
The MS Build project file format is used by Visual Studio to store information about projects it manages. Project files can be evaluated (or run) on the command line ( cmd.exe , PowerShell) with MSbuild.exe .
A PROJ file is a project file created in Microsoft Visual Studio, a software development tool used to create Windows programs and web applications. It contains XML-formatted text that defines a project's content, platform requirements, versioning information, and web server or database server settings.
After looking at your comment again I realized that I mis-intrepreted what you really needed. This is an interesting problem you have on your hands.
If you don't mind editing the project file itself you may be able to get pretty close to what you want. There is an item FileWrites that keeps track of all the files that were written out during the build process. To start playing around with this edit the project file to have this AfterBuild target
<Target Name="AfterBuild">
<Message Text="FileWrites: @(FileWrites)" Importance="high"/>
</Target>
There are some problems with this approach as well
You might think that you could solve the first problem with the MSBuild: Find Many Project References technique and output the FileWrites item after doing a build. This will only work if the wrapper proj file was placed in the same folder as the original project itself because all the items inside of a .csproj file are declared with a relative path. So there goes that for the most part.
You can get over the second limitation by using the FindUnderPath task to only get the files placed in the OutputPath folder.
What you could do but is not really reliable either is to examine the OutputPath at the begining of the build and then once again at the end of the build nad see what was added. Let's say that you put the original files into an item StartFiles and at the end of the build put all the files into an item named EndFiles you could the do:
<Target Name="SomeTargetHere">
<ItemGroup>
<FilesWritten Include="@(EndFiles)" />
<FilesWritten Remove="@(StartFiles)"/>
</ItemGroup>
<!-- Now FilesWritten contains the difference between EndFiles & StartFiles -->
</Target>
In short I'm not sure if there is a good solution that doesn't involve either a custom task or a custom logger :(.
Sayed Ibrahim Hashimi
My Book: Inside the Microsoft Build Engine : Using MSBuild and Team Foundation Build
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With