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

From the TeamCity 2019.1 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.

and

The optional part starting with the => symbols and followed by the target directory name can be used to publish the files into the specified target directory. If the target directory is omitted, the files are published in the root of the build artifacts. You can use "." (dot) as a reference to the build checkout directory. The target paths cannot be absolute. Non-relative paths will produce errors during the build.

Two key points here:

  1. If you use a wildcard in the source specifier TeamCity will preserve the directory structure from the first wildcard in the specification. Using your examples SomeLibrary\bin\Release\*.dll does not preserve the directory structure because the lone wildcard only specifies files while **\bin\Release\*.dll will preserve the directory structure because of the first wildcard that will match directories
  2. If you omit the target directory (just use =>) any found artifacts, with preserved directory structures, will be placed at the root of the artifacts tree. Using your example SomeLibrary\bin\Release\*.dll => will place SomeLibrary.dll and SomeDependency.dll at the root of the artifacts tree while **\bin\Release\*.dll => will place the two files in the folder SomeLibrary\bin\Release under the root of the artifacts tree.

Tags:

Teamcity