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
Take a look at my previous blog entry MSBuild: Find Many Project References. In that post I describe how you can create an MSBuild file which could extract out the values for the Reference ItemGroup. In your case just replace the target that I created with one that populated an item from all the files found in the OutputPath. Let me know if you want me to expand on that.
If you are using the MSBuild task then you can get the files that were built by using the TargetOutputs output. Here is an example
<MSBuild Projects="YourProject.csproj">
<Output ItemName="YourProjectOutputs" TaskParameter="TargetOutputs"/>
</MSBuild>
So in this case when YourProject.csproj is built the files that were created would be placed inside the YourProjectOutputs item.
I've created a blog entry a while ago that talks in more detail about this, MSBuild: How to Get All Generated Outputs.
Sayed Ibrahim Hashimi
My Book: Inside the Microsoft Build Engine : Using MSBuild and Team Foundation Build
What we do the combat this scenario is that each build creates a "Deploy" directory (you could call it what ever you want).
The deploy directory contains only those executables and dlls that are needed for the actual app (ie, testing dlls don't get put there). Each project would need to get its "Deployable" stuff into that directory (We even add subdirectories (ie. Web, Services etc).)
It duplicates some bits, but it lets you have access to all the dlls from a build if they are needed.
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