Can you have more than one target?

Jun 1, 2010 at 10:20 PM
Edited Jun 1, 2010 at 11:57 PM

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)" />
      // list of js includes here.

    </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)" />
      // list of js includes here.

    </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)" /> // list of js includes here. </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.

        
    
    

Coordinator
Jun 7, 2010 at 1:20 AM

Hi Chobo2,

 

can you try renaming the JavaScriptFiles idetifier in the second task, Task 2, to something else .. like...

 

<Target Name="Test2">
<ItemGroup>
        <JavaScriptFiles Remove="@(JavaScriptFiles_2)" />
// list of js includes here.

</ItemGroup>
<CompressorTask
JavaScriptFiles="%(JavaScriptFiles_2.Identity)"
ObfuscateJavaScript="True" ....
/>


Does that work?
Jun 8, 2010 at 7:20 PM
purekrome wrote:

Hi Chobo2,

 

can you try renaming the JavaScriptFiles idetifier in the second task, Task 2, to something else .. like...

 

<Target Name="Test2">
<ItemGroup>
        <JavaScriptFiles Remove="@(JavaScriptFiles_2)" />
// list of js includes here.

</ItemGroup>
<CompressorTask
JavaScriptFiles="%(JavaScriptFiles_2.Identity)"
ObfuscateJavaScript="True" ....
/>


Does that work?

No that does not seem to do anything.
Jul 23, 2010 at 6:33 AM

Found an answer on stack overflow for those interested. Its as simple as...

<Target Name="Test2" AfterTargets="Test1">

http://stackoverflow.com/questions/1112913/why-does-msbuild-not-execute-multiple-targets

Coordinator
Sep 9, 2010 at 12:45 AM

BTW cpt_shiner, you don' t need two targets to have two CompressorTasks. Check out the end of my video tutorial, on the homepage of this project for an example of multi-CompressorTasks.