tags:

views:

51

answers:

1

Some of my .csproj project files have special target "AssembleJS" that merges all .js files included in project in one big file (i.e. webcontrols.csproj has target "AssembleJS" with output "webcontrols.js").

So if I have project parts.csproj

  1. That has target AssembleJS.
  2. References project webcontrols.csproj.
  3. References utility project utils.csproj that does not have any JavaScript and does not have AssembleJS target.

I want target AssembleJS of parts.csproj execute AssembleJS in webcontrols.csproj (the same was as MSBuild works with standard Build target).

Something like

<MSBuild Project="@ReferencedProjects" Targets="AssembleJS"/>

does not work because utils.csproj does not have target AssembleJS.

Is there any way to filter @ReferencedProjects based on whether project has certain target?

Any other idea on how to handle this scenario?

+1  A: 

You cannot do what you are requiring. But you might be able to acheive it with batching.

<Project xmlns=''>
    <ItemGroup>
        <ReferencedProjects Include="webcontrols.csproj">
            <Type>Web</Type>
        </ReferencedProjects>
        <ReferencedProjects Include="utils.csproj">
            <Type>NonWeb</Type>
        </ReferencedProjects>
    </ItemGroup>

   <Target Name="BuildWebProjects">
        <MSBuild Projects="@(ReferencedProjects)" Condition=" '%(ReferencedProjects.Type)' == 'Web' " />
   </Target>

</Project>

Do a search for MSBuild Batching and find some results on sedodream.com for more info.

Should I expand on this?

Sayed Ibrahim Hashimi
It's probably the best option MSBuild has, but amount of manual work it creates makes it unusable for me.
mbergal
And one more things, it is "ProjectReference", not "ReferencedProjects"
mbergal
Ok, I was just going of the names you created in your example.
Sayed Ibrahim Hashimi