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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:41:33+00:00 2026-06-13T12:41:33+00:00

Currently, I’ve got he following code in an MSBuild proj file. It’s really simple.

  • 0

Currently, I’ve got he following code in an MSBuild proj file. It’s really simple. Define 4 variables and call my MSBuild Task once-per-variable :

Code please ~~

<ItemGroup><JS_File1 Include="file1.js"/></ItemGroup>
<ItemGroup><JS_File1 Include="file2.js"/></ItemGroup>
<ItemGroup><JS_File1 Include="file3.js"/></ItemGroup>
<ItemGroup><JS_File1 Include="file4.js"/></ItemGroup>

<JavaScriptCompressorTask SourceFiles="@(JS_File1)" OutputFile="@(JS_File1).min"/>
<JavaScriptCompressorTask SourceFiles="@(JS_File2)" OutputFile="@(JS_File2).min"/>
<JavaScriptCompressorTask SourceFiles="@(JS_File3)" OutputFile="@(JS_File3).min"/>
<JavaScriptCompressorTask SourceFiles="@(JS_File4)" OutputFile="@(JS_File4).min"/>

Nothing exciting at all.

I was wondering if this could be refactored to something like this.

Fail-Pseudo-Code ~~

<ItemGroup>
    <JS_File1 Include="file1.js"/>
    <JS_File1 Include="file2.js"/>
    <JS_File1 Include="file3.js"/>
    <JS_File1 Include="file4.js"/>
</ItemGroup>

<!-- now this is the shiz i have no idea about -->
foreach(@(JS_Files))
    <JavaScriptCompressorTask SourceFiles="@(theFile)" OutputFile="@(theFile).min"/>

Is it possible to do this, in MSBuild?

So that task is called once-per-file .. or more to the point, once-per-item-in-the-item-group?

  • 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-06-13T12:41:34+00:00Added an answer on June 13, 2026 at 12:41 pm

    You can use item metadata to batch the task (see http://msdn.microsoft.com/en-us/library/ms171474.aspx).

    All items have metadata called ‘Identity,’ which contains the value of the Include attribute. If you use metadata reference syntax %(Identity), that will instruct MSBuild to execute your task for each unique Include value.

    <ItemGroup>
        <JS_File1 Include="file1.js"/>
        <JS_File1 Include="file2.js"/>
        <JS_File1 Include="file3.js"/>
        <JS_File1 Include="file4.js"/>
    </ItemGroup>
    
    <JavaScriptCompressorTask SourceFiles="@(JS_File1)" OutputFile="%(Identity).min"/>
    

    Note that MSBuild knows that you are referencing the Identity metadata of the JS_File1 item group because you reference it in the task. Otherwise you would need to use the syntax %(JS_File1.Identity).

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

Sidebar

Related Questions

Currently I have the following code to update the NSLevelindicator: [self.headerIndicator selfFloatValue:heightValue] Is there
Currently, I have the following XAML code which is able to achieve the following
Currently I have the following statement in my code to allow me to debug
Currently I have this code: <?php echo '<meta name=robots content=noindex>'; $arr = json_decode(file_get_contents(http://media1.clubpenguin.com/play/en/web_service/game_configs/ paper_items.json),true);
Currently I have the following Mapping in my Controller: @RequestMapping( value = /add.html, method
Currently, I have a log file of messages in one table in a MySQL
Currently I have in my code tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(addCompoundToLabel:)]; My code
I want use html5's new tag to play a wav file (currently only supported
Currently I am responsible for a service: To make a Http Get call on
Currently have the following expression: @[TMS_Dest] + \\ + @[TMS_Rename] + (DT_WSTR,4)DatePart(yyyy, GetDate()) +

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.