开发者

Checking if project has a specific target in MSBuild

开发者 https://www.devze.com 2022-12-12 02:41 出处:网络
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 \"webcon

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开发者_Python百科 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?


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消