Publish an Web Application with Team City

I've figured out how to publish an Web Application with Team City using the sln2008 runner and thought that I'd share.

In step 6 of the Build Configuration add a System Property name OutDir (I'm not sure if case matters or not) and give a value of something arbitrary like "publish/" (do not include the quotes). I found that it is picky it didn't like the "\" but maybe you could try escaping it and that would work.

Then inside the the csproj file for the web application, open it in Notepad and find the AfterBuild element, ususally it is commented out towards the bottom of the file.

  <Target Name="AfterBuild">
    <Exec Command="xcopy &quot;$(WebProjectOutputDir)&quot; &quot;\\server\;"/>

I was using beyond compare with a script but changed this sample to use xcopy for shortness.

Comment actions Permalink

Hi David,

I guess I am trying to do the same thing. I've tried your method but I can't get the section to execute at all.

The second approach I've taken is to put on configuration screen "#3 - Runner: sln2008" the word "Publish" in the Targets field expecting TC do do a publish just like I can do from VS2008 when I right click on project and select "publish" from there. The message I get is:

[Project "Portal.csproj" (Publish target(s)):] Skipping unpublishable project.

However the project is clearly publishable as I am able to publish it from VS2008.

Thanks in advance for any suggestion.

Filip Kierzek

Comment actions Permalink

You could also use RoboCopy:

        <Exec Command="robocopy /MIR $(OutputPath) $(OutputWebSite) /NP /XF Web.*.config *.t" IgnoreExitCode="true">
            <Output TaskParameter="ExitCode" PropertyName="ExitCode"/>

/XF means exclude file, and I'm excluding the transformations files for web.config.

RobyCopy is generally better made than xcopy from my own experience. It can be downloaded for Server 2003 here:
and exists already for versions above that.


Please sign in to leave a comment.