views:

115

answers:

3

Edit 4 (Edit 1 to 3 removed as they where solved)

My last problem is that I would like multiple targets but it does not seem to work. I have to stick them all into the same target what kinda sucks since it would nice to different names so I got to change something I can just look at the target name.

Hi

I am trying to get my MsBuild and it works....if all my stuff is in the same target tag. If I have multiple tags it only does the first one and that's it. None of the other targets are done.

<Target Name="Test1">
    <ItemGroup>
      <JavaScriptFiles Remove="@(JavaScriptFiles)" />
  <JavaScriptFiles Include="..\PathHere\Javascript.js"/>

</ItemGroup>
<CompressorTask
      JavaScriptFiles="%(JavaScriptFiles.Identity)"
      ObfuscateJavaScript="True"
      PreserveAllSemicolons="False"
      DisableOptimizations="Nope"
      EncodingType="Default"
      DeleteJavaScriptFiles="false"
      LineBreakPosition="-1"
      JavaScriptOutputFile="../Path/Here/(JavaScriptFiles.FileName).min.js"
      LoggingType="ALittleBit"
      ThreadCulture="en-au"
      IsEvalIgnored="false"
        />

<ItemGroup>    
  <JavaScriptFiles Remove="@(JavaScriptFiles)" />
   <JavaScriptFiles Include="..\PathHere\Javascript2.js"/>

</ItemGroup>
<CompressorTask
      JavaScriptFiles="%(JavaScriptFiles.Identity)"
      ObfuscateJavaScript="True"
      PreserveAllSemicolons="False"
      DisableOptimizations="Nope"
      EncodingType="Default"
      DeleteJavaScriptFiles="false"
      LineBreakPosition="-1"
      JavaScriptOutputFile="../Path/Here/%(JavaScriptFiles.FileName).min.js"
      LoggingType="ALittleBit"
      ThreadCulture="en-au"
      IsEvalIgnored="false"
        />


  </Target>

So the above works. If I do this

    <Target Name="Test2">

        <ItemGroup>    
          <JavaScriptFiles Remove="@(JavaScriptFiles)" />
           JavaScriptFiles Include="..\PathHere\Javascript3.js"/>
    </ItemGroup>
    <CompressorTask
          JavaScriptFiles="%(JavaScriptFiles.Identity)"
          ObfuscateJavaScript="True"
          PreserveAllSemicolons="False"
          DisableOptimizations="Nope"
          EncodingType="Default"
          DeleteJavaScriptFiles="false"
          LineBreakPosition="-1"
          JavaScriptOutputFile="../Path/Here/%(JavaScriptFiles.FileName).min.js"
          LoggingType="ALittleBit"
          ThreadCulture="en-au"
          IsEvalIgnored="false"
            />

</Target>

Then the first target will go and the above one will do nothing.

A: 

You should be able to do this by modifying the msbuild script in the .proj file of your project.

Here is a link to MsBuild --

http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx

Enjoy!

Doug
+1  A: 

Looks like this is a good place to start:

http://yuicompressor.codeplex.com/

They boast:

Visual Studio post-build event intergration! :) (with detailed instructions...

spender
Hmm looks interesting. But will this make it all into one file? Or can you set it too output it to multiple files? I have something that combines the files dynamically and gzips them. http://code.msdn.microsoft.com/HttpCombiner
chobo2
A: 

I'm not sure, but it looks like there is some confusion about MSBuild variable access. There are three ways to access variables with msbuild.

$()  Extracts the value of a property
@()  Extracts the value of an item as a list, that is, vector
%()  Extracts value of an item as a single string, that is, scalar

It looks like you actually want to be using @() where you are using %() but I'll confess I'm having a hard time understanding exactly what your problem is. You said it "will do nothing" but chances are it's doing something, even if it doesn't appear to be doing anything.

more here

slf
Well lets put it this way. It is not doing what I want. I want to have separate target names(I don't know what they really do) but when I have multiple target names only the ones in the first target name do what I want(generate minified files). The rest don't do this.
chobo2