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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:33:35+00:00 2026-05-23T19:33:35+00:00

I’m having some problems witht the scoping of item groups I create in an

  • 0

I’m having some problems witht the scoping of item groups I create in an MSBuild script. Basically, what I want to do is to have two different targets – let’s call them RunUnitTests and RunIntegrationTests – that generate an item group called TestAssemblies and then call RunTests, which uses TestAssemblies to determine which assemblies to run tests from.

The two different targets for unit and integration tests both depend on the build target and get an item group with all compiled assemblies from there, but since the RunTests target will be called from different places, it can’t really depend on either of them. Thus, I need to pass the item group to the common testrunner target somehow. However, this seems to be impossible, because changes to an item group within a target seems to be scoped to only work within that target.

I’ve seen these posts, but they only seem to confirm my fears, and suggest DependsOnTarget as a workaround – which won’t work for me, since I need to get the items from different places on different runs.

This is what I have so far:

<Target Name="RunAllTests" DependsOnTarget="BuildProject">
    <!-- In here, items created in BuildProject are available. -->
    <CallTarget Targets="RunUnitTests;RunIntegrationTests">
</Target>

<Target Name="RunUnitTests" DependsOnTarget="BuildProject">
    <!-- In here, items created in BuildProject are available. -->
    <!-- One of those is @(UnitTestAssemblies) -->

    <CreateItem Include="@(UnitTestAssemblies)">
        <Output TaskParameter="Include" ItemName="TestAssemblies" />
    </CreateItem>

    <CallTarget Targets="RunTests" />
</Target>

<!-- Then there's a similar target named RunIntegrationTests, which does the
     same as RunUnitTests except it includes @(IntegrationTestAssemblies) -->

<Target Name="RunTests">
    <!-- Here, I'd like to access @(TestAssemblies) and pass them to the NUnit
         task, but they have fallen out of scope. -->
</Target>

Is there any way around this, or will I have to completely restructure my build script?

  • 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-23T19:33:35+00:00Added an answer on May 23, 2026 at 7:33 pm

    Changes to an item group within a target are only visible to other targets after the changing target exits. So to get the list of test assemblies to stick, you may have to move actually setting up the targets to its own target as in the following:

    <Target Name="PrepareUnitTestList" DependsOnTarget="BuildProject">
      <ItemGroup>
        <TestAssemblies Include="@(UnitTestAssemblies)"/>
      </ItemGroup>
    </Target>
    
    <Target Name="RunUnitTests" DependsOnTargets="PrepareUnitTestList">
      <CallTarget Targets="RunTests"/>
    </Target>
    
    <Target Name="RunTests">
      <Message Text="Test: %(TestAssemblies.Identity)"/>
    </Target>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I have some data like this: 1 2 3 4 5 9 2 6
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.