13

I have a TeamCity Build Configuration that includes the following to publish artifacts:

Source\Builder\bin\Release\*.dll=>release

This works fine, however I am wanting to exclude one dll (there are quite a few) and have read that you can use + & - operators to do this. Something along the lines of:

+: Source\Builder\bin\Release\*.dll=>release
-: Source\Builder\bin\Release\Builder.*

As soon as I add these in, no artifacts are published and I get the following error in the build log (looks like it is counting the + as part of the path):

[Publishing artifacts] Collecting files to publish [+:Source\Builder\bin\Release\*.dll=>release]
[Publishing artifacts] Artifacts path +:Source/Builder/bin/Release/*.dll not found

I am using version 7.1.1, anyone any ideas (I am not sure whether these operators are even valid). I have seen a solution with MSBuild but am surprised this functionality is not available.

Thanks in advance.

Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121
Monkeeman69
  • 502
  • 2
  • 5
  • 18
  • +1 as I came across the same problem. Are you publishing the artefacts to use elsewhere in TeamCity as an artefact dependency or because you want to use the binaries externally to TC? – infojolt Oct 08 '12 at 11:20
  • I wanted to use artifacts as a downloadable release for external use really. – Monkeeman69 Oct 08 '12 at 11:24

3 Answers3

7

I don't believe you can.

However, if you are using the artifacts in another build configuration as an artifact dependency, you can exclude a particular file there.

When you set up the dependencies, you can specify a negative operator like this:

+:release/**=>Dependencies/SomeProject
-:release/SomeBinary.dll

It is a horrible hack, but one way you could get it to work would be to set up a new build configuration which gets the dependencies as an artifact dependency, excluding the one binary, and then publishes its own artifacts.

As in, create a new build configuration and publish:

Dependencies/SomeProject=>release

Then reference the artifacts from this build configuration instead of the other one.

ljk
  • 488
  • 1
  • 5
  • 11
infojolt
  • 5,244
  • 3
  • 40
  • 82
  • Ah, this is maybe where I have read this and was getting confused (only new to TC, migrating from CruiseControl). – Monkeeman69 Oct 08 '12 at 11:25
  • It is a horrible hack, but one way you could get it to work would be to set up a new build configuration which gets the dependencies as an artefact dependency, excluding the one binary, and then publishes its own artefacts. – infojolt Oct 08 '12 at 11:27
  • Thinking about it, this was for my CI build. I guess I could copy everything there and have a new Release configuration that just takes the things it needs. – Monkeeman69 Oct 08 '12 at 11:28
  • Seems like we just had the same thought! Not ideal really, but I guess it will have to do for now. Thanks – Monkeeman69 Oct 08 '12 at 11:29
5

A little bit late for the party, but there is still no fix...

I ended up adding a last build step to the project. It is command line > custom script. Then I used this commands to remove the files that I didn't want in the artifacts. This runs just before artifacts collection.

del /S /Q "src\apps\*.xml" 
del /S /Q "src\apps\*.pdb"

Explanation for del command

/S  Delete from all Subfolders (DELTREE)
/Q  Quiet mode, do not give a Yes/No Prompt before deleting
 *  Match any characters
oleksii
  • 35,458
  • 16
  • 93
  • 163
  • Thanks @oleksii! This pointed me to the right direction. I needed to have three separate config files that needed to be deployed based on the environment (dev, qa & stage). I've configured the custom script to delete the default config first and then replace it with the specific environment config by renaming for example web.dev.config to web.config. – hatsrumandcode Oct 26 '16 at 09:11
2

Our current options are to vote for this feature request at http://youtrack.jetbrains.com/issue/TW-5244 and fail back to workarounds.

TeamCity artifact paths combine folders question hints that the same target folder can be reused for multiple path patterns.

TeamCity docs also state that

TeamCity will create directories starting from the first occurrence of the wildcard in the pattern.

So in many cases it's possible to inverse exclusion problem to multiple inclusions.

For example, instead of lurking how to exclude -:**/.svn from my templates I was able just to filter them by extension:

templates/**/*.vm => templates
templates/**/*.xsl => templates
Community
  • 1
  • 1
Vadzim
  • 24,954
  • 11
  • 143
  • 151