Bin folder is not copied from MSBuild, Teamcity

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" 
+4
source share
1 answer

I think this is the problem of evaluating subjects. Your "BinFolder" element is interpreted the first time MsBuild reads your assembly file, i.e. Before assembly. And I think $ (ProjectDir) bin ***. * Empty before assembly. To avoid this, you can declare your cell in your target, as shown below:

 <Target Name="AfterBuild"> <CallTarget Targets="Move" /> </Target> <Target Name="Move"> <ItemGroup> <BinFolder Exclude="*.cs" Include="$(ProjectDir)bin\**\*.*"/> </ItemGroup> <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> <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> 

Or you could try using the CreateItem task:

 <Target Name="Move"> <CreateItem Exclude="*.cs" Include="$(ProjectDir)bin\**\*.*"> <Output TaskParameter="Include" ItemName="TheFiles"/> </CreateItem> <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> 

Here you can find more information:

+5
source

All Articles