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 6732659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:40:36+00:00 2026-05-26T10:40:36+00:00

I am seeing some strange behavior with the ItemGroup tag. My application depends on

  • 0

I am seeing some strange behavior with the ItemGroup tag.

My application depends on several DLLs, and I am copying these DLLs as well as the executable to a deploy directory, which is used by NSIS to create an install package from a fresh build. However, I am running into an odd issue with this.

I define my ItemGroup as follows (at the top of the file before I define my build target:

<MyAppFiles Include="$(ProjectRoot)\$(OutputPath)\*.dll;$(ProjectRoot)\$(OutputPath)\MyApp.exe" />

So, this grabs all the DLLs in the directory as well as the binary MyApp.exe. But, if the project has been cleaned (i.e., there are no files in $(OutputPath)). The DLLs are not included in the ItemGroup list of files. Now, if I follow this up with another build, (i.e., there are files from the previous build in $(OutputPath)) the ItemGroup contains all the files I want.

Also, I have checked the output of the build script and the DLLs are copied to $(OutputPath) whether a clean happened or not.

So, my question is, how do I correct my build script such that ItemGroup always contains the DLLs? It seems like the ItemGroup populates with files before the build happens, so if the files aren’t there before the build, they aren’t included in the list, but if they exist before the build then they are.

For reference, here is the build target that I am using:

<PropertyGroup>
    <MyAppRoot>..\MyApp</MyAppRoot>
    <MyAppProject>$(MyAppRoot)\MyApp.csproj</MyAppProject>
<PropertyGroup>

<Target Name="BuildProject">
    <Message Text="BEFORE: @(ProjectFiles)" />
    <MSBuild Projects="$(MyAppProject)" Targets="Build" Properties="Configuration=$(Configuration)">
      <Output TaskParameter="TargetOutputs" ItemName="MyAppAssembly"/>
    </MSBuild>
    <Message Text="AFTER: @(ProjectFiles)" />
  </Target>
  • 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-26T10:40:37+00:00Added an answer on May 26, 2026 at 10:40 am

    Presumably your item array is declared at the root level in your project, in XML as a child of the <Project> element. This means that MSBuild will evaluate the membership in the item array when the project file is first loaded. Whether or not the existance of those files changes during execution is irrelevant. If you want to populate the item array at a particular point in your build, you need to change the declaration from a static item array to a dynamic one, which means moving it inside a target, to the exact spot where you want to gather the files, as:

    <Target Name="BuildProject">
       ...before message
       ...msbuild task
       <ItemGroup>
          <ProjectFiles Include="$(ProjectRoot)\$(OutputPath)\*.dll" />
          <ProjectFiles Include="$(ProjectRoot)\$(OutputPath)\MyApp.exe" />
       </ItemGroup>
       ...after message
    </Target>
    

    (excerpted from trick #62 in the book “MSBuild Trickery“)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was seeing some strange behavior in a multi threading application which I wrote
I am seeing some strange behavior with my application and the state of its
I'm using JBoss Seam 2.2 in my application, and am seeing some strange behavior
I'm using MVC3 .NET4.0 (VB), and I'm seeing some strange behavior on a simple
I am developing an OpenGL application and I am seeing some strange things happen.
I'm seeing some strange behavior when I run Rails server with rails s -e
Seeing some strange behavior, whereby connecting to Oracle database, and then calling external function,
I'm seeing some strange behavior when rounding in SQL Server 2008. Given the following
I use GoogleMock/GoogleTest for testing, and I'm seeing some strange behavior when a matcher
Seeing some strange behavior in my IDE and thought I'd run it by ya.

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.