Tutorial :How do you get TeamCity to flatten a directory when it creates artifacts


We are using TeamCity 5.0 to build a C# solution using the sln2008 build runner. We have multiple projects that produce exe files. We want to use TeamCity's artifacts feature to flatten all the directories. We want all the files to go into one folder with no sub folders no matter which folder it came from. TeamCity keeps the directory hierarchy when it created the artifacts.

Our artifacts are created using


What we get is

  • PublishedFiles\FooProject\bin\Release\Foo.exe
  • PublishedFiles\BarProject\bin\Release\Bar.exe

What we want is

  • PublishedFiles\Foo.exe
  • PublishedFiles\Bar.exe


TeamCity 5.1 will get us closer.

The pattern

SomeLibrary\bin\Release\*.dll => PublishedFiles  

will get us

  • PublishedFiles\SomeLibrary.dll
  • PublishedFiles\SomeDependency.dll


**\bin\Release\*.dll => PublishedFiles  

Will still keep the structure that we don't want.

Currently we use MSBuild to flatten the structure and then TeamCity to archive it. It would be nice to skip the MSBuild part.


From the TeamCity 5.x Documentation :

The files will be published preserving the structure of the directories matched by the wildcard (directories matched by "static" text will not be created). That is, TeamCity will create directories starting from the first occurrence of the wildcard in the pattern.


In any case you could move you DLLs to new directories and publish them.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »