Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3282830
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:58:19+00:00 2026-05-17T19:58:19+00:00

I have a very odd issue, where I’ve created a custom MSBuild task that

  • 0

I have a very odd issue, where I’ve created a custom MSBuild task that would move all files I need for my MVC project to a specific location so that we can publish it. This works fine when I trigger the script localy on my machine but as soon as I check this changes in and Teamcity runs the script, it copies everything except from the Bin folder.
However, if run MSbuild directlly from the command line (same script), it does copy the bin folder. I don’t understand why this isn’t working when TeamCity is building 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 paramanter I’m passing in from Teamcity & manually in the command line.

/p:ArtifactsDir="%system.agent.work.dir%\WebProject\trunk\Website"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:58:20+00:00Added an answer on May 17, 2026 at 7:58 pm

    I think it’s a problem of items evaluation. Your “BinFolder” item is interpreted at the first time MsBuild read your build file, i.e. before the build. And I think that $(ProjectDir)bin***.* is empty before the build. To avoid this you can declare your binfolder within your target as shown :

    <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 else you could try using 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>
    

    You can find more information here :

    • MSBuild ItemGroup Include/Exclude pattern issue
    • http://blogs.msdn.com/b/msbuild/archive/2006/01/03/508629.aspx
    • http://www.sedodream.com/PermaLink,guid,dd6cb1db-c0e4-47f7-ad84-6e59ff6b03d0.aspx
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.