I have a very strange problem when I created a custom MSBuild task that would move all the files that I need for my MVC project to a specific location so that we can publish it. This works fine when I run a local script location on my machine, but as soon as I check these changes and Teamcity runs the script, it copies everything except from the Bin folder. However, if you run MSbuild directly from the command line (the same script), it copies the bin folder. I do not understand why this does not work when TeamCity builds it.
Does anyone have an idea why this is happening and how to solve it?
<Target Name="AfterBuild"> <CallTarget Targets="Move" /> </Target> <Target Name="Move"> <Copy SourceFiles="@(BinFolder)" DestinationFolder="$(ArtifactsDir)\Webproject.Web\bin" /> <Copy SourceFiles="@(ContentFolder)" DestinationFolder="$(ArtifactsDir)\SchrodersFundEngine.Web\Content" /> <Copy SourceFiles="@(ImagesFolder)" DestinationFolder="$(ArtifactsDir)\SchrodersFundEngine.Web\Images" /> <Copy SourceFiles="@(ScriptsFolder)" DestinationFolder="$(ArtifactsDir)\SchrodersFundEngine.Web\Scripts" /> </Target> <ItemGroup> <BinFolder Exclude="*.cs" Include="$(ProjectDir)bin\**\*.*"/> <ContentFolder Exclude="*.cs;*.svn-base" Include="$(ProjectDir)Content\*.css"/> <ImagesFolder Exclude="*.cs;*.svn-base" Include="$(ProjectDir)Images\*.*"/> <ScriptsFolder Exclude="*.cs;*.svn-base" Include="$(ProjectDir)Scripts\*.js"/> </ItemGroup>
$ (ArtifactsDir) is a parameter that I pass from Teamcity and manually on the command line.
/p:ArtifactsDir="%system.agent.work.dir%\WebProject\trunk\Website"
source share