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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:35:00+00:00 2026-05-26T17:35:00+00:00

I just started playing around with MSBuild this evening and am porting an nAnt

  • 0

I just started playing around with MSBuild this evening and am porting an nAnt build script over to MSBuild. Compiling seems pretty straight forward, but one thing I want to do is run a Java program against every file in a directory. I finally got it working, but it seems hacky and I’m quite sure there’s a cleaner way to do this. Here’s my code:

<!-- Crunch Files -->
<ItemGroup>
   <ToCrunch Include="$(BuildDir)/WWW/Scripts/kpc*.js;$(BuildDir)/WWW/Styles/*.css" />
</ItemGroup>
<ConvertToAbsolutePath Paths="@(ToCrunch)">
  <Output TaskParameter="AbsolutePaths" ItemName="AbsoluteFiles" />
</ConvertToAbsolutePath>

<Message Text="Crunching Script Files..." />
<Exec WorkingDirectory="Crunch" Command="Java.exe -jar yuicompressor-2.4.2.jar %(AbsoluteFiles.Identity) -o %(AbsoluteFiles.Identity) --charset utf-8" />

Here’s my issues with the above approach:

  • I have to set the working directory to Crunch where java.exe lives, EVEN THOUGH Java.exe is in the system path and should just work.

  • Because I change the working directory, the included files in the ItemGroup are no longer relative to the working directory so now I have to convert them all to their absolute paths.

  • This program is very slow, and takes several seconds per file. So what I get is “Crunching script files” and then a 20 second delay or so. I would like to output a message to the screen for each file being processed instead.

Here’s the exact same thing in nAnt:

      <!-- Crunch Javascript/CSS Files -->
  <foreach item="File" property="filename">
     <in>
        <items>
           <include name="${build.dir}/WWW/Scripts/kpc*.js" />
           <include name="${build.dir}/WWW/Styles/*.css" />
        </items>
     </in>
     <do>
        <echo message="Crunching File ${filename}" />
        <exec program="Crunch/java">
           <arg value="-jar" />
           <arg value="Crunch/yuicompressor-2.4.2.jar" />
           <arg file="${filename}" />
           <arg value="-o" />
           <arg file="${filename}" />
           <arg line="--charset utf-8" />
        </exec>
     </do>
  </foreach>

If anyone has any ways to fix any of the above issues, I’d greatly appreciate it. Thanks!

  • 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-26T17:35:01+00:00Added an answer on May 26, 2026 at 5:35 pm

    I ended up solving this by using the FullPath property instead of the Identity property, which gives the full path.

    Why MSBuild doesn’t find programs even if they’re in the system path is a mystery.

    Also, there’s a .NET Port of YUI Compressor which has MSBuild support – I plan on trying this out which would make the issue no longer relevant.

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

Sidebar

Related Questions

I've just started playing around with Kickstrap and I can't get the build script
I've just started playing around with android, so pardon me if this is a
I've just started playing around with Knockout.js, and it seems really cool. What I
Good evening, I just started playing around with C# and I tried creating a
I just started playing around with Phing build scripts (built with PHP). From what
I just started playing around with JSON and I have created this example. var
I've just started playing around with Android Licensing and I ran into this problem.
Just started playing around with ice_cube I've got a weekly schedule (with a granularity
I just started playing around with threading today and I ran into something that
I just started playing around with the 960 CSS framework and found that it

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.