简体   繁体   中英

How to execute a target in MSBuild after project references have been built?

Say I have a project depending on another:

<?xml version="1.0" encoding="utf-8"?>
<Project ...>
  ...
  <ItemGroup>
    <ProjectReference Include="p1.csproj">
      <Project>{456a45c3-764a-4a7c-8ad4-d83d61cc89bb}</Project>
      <Name>P1</Name>
    </ProjectReference>
  </ItemGroup>

  <Target Name="RunAfterBuildingProjRefs" AfterTargets="???">
    ...
  </Target>
</Project>

To ensure that target RunAfterBuildingProjRefs is executed after all project references ( p1 ) are built, what target should I specify in its AfterTargets attribute?

You can use AfterResolveReferences as a hook target to run after all references have been resolved. This also includes COM and native references - if you really want project references only, then hooking after ResolveProjectReferences is also an option.

See The ProjectReference Protocol for details about how project-to-project references work and which targets are involved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM