MSBuild copy output from another project into the output of the current project

早过忘川 提交于 2019-11-29 07:25:15

I have made this work, though I would love to find a cleaner solution that takes advanctage of the built-in parameters within MSBuild (like $(TargetDir), etc but to point at the project I want to grab the output for). Anyway, here is what I've done:

<Target Name="AfterBuild">
<Copy SourceFiles="$(SolutionDir)MyProject.Dal.Linq\bin\$(Configuration)\MyProject.Dal.Linq.dll" DestinationFolder="$(TargetDir)"/>
</Target>

I would love to see a cleaner solution, but this should do for now.

So, you want to have a reference, but not have it visible in VS. So you want it built if needed, and copied to output like any other Content file. Here's how you'd do it:

<Target Name="IncludeDALImplementation" BeforeTargets="AfterBuild">
  <MSBuild Projects="..\DalImplementation\DAL.csproj" BuildInParallel="$(BuildInParallel)" Targets="Build">
    <Output TaskParameter="TargetOutputs" ItemName="DalImplementationOutput" />
  </MSBuild>

  <ItemGroup>
    <Content Include="@(DalImplementationOutput)" />
  </ItemGroup>
</Target>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!