MSBuild 将依赖项项目的输出复制到另一个文件夹中
我有一个项目有几个项目依赖项,我想将两个依赖项目的输出(dll)放入另一个文件夹中,但它似乎不起作用。以下是我的情况,请问有什么问题吗?
<ItemGroup>
<ProjectReference Include="..\..\a\a.csproj">
<Project>{xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}</Project>
<Name>Client</Name>
</ProjectReference>
<ProjectReference Include="..\..\b\b.csproj">
<Project>{yyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy}</Project>
<Name>Server</Name>
</ProjectReference>
</ItemGroup>
<Target Name="BuildOtherProjects">
<MSBuild Projects="@(ProjectReference)" Targets="Build">
<Output TaskParameter="TargetOutputs" ItemName="DependentAssemblies" />
</MSBuild>
<Copy SourceFiles="@(DependentAssemblies)" DestinationFolder="$(OtherBuildLocation)\Build\Output" SkipUnchangedFiles="true" />
</Target>
I have a project that have a couple project dependencies, I want to throw the output (dll) of the two dependent project into another folder, but it doesn't seem to work. The following is something what I have, is there anything wrong?
<ItemGroup>
<ProjectReference Include="..\..\a\a.csproj">
<Project>{xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}</Project>
<Name>Client</Name>
</ProjectReference>
<ProjectReference Include="..\..\b\b.csproj">
<Project>{yyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy}</Project>
<Name>Server</Name>
</ProjectReference>
</ItemGroup>
<Target Name="BuildOtherProjects">
<MSBuild Projects="@(ProjectReference)" Targets="Build">
<Output TaskParameter="TargetOutputs" ItemName="DependentAssemblies" />
</MSBuild>
<Copy SourceFiles="@(DependentAssemblies)" DestinationFolder="$(OtherBuildLocation)\Build\Output" SkipUnchangedFiles="true" />
</Target>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,它在什么时候失败了?尝试将一些消息任务设置为重要性=“高”(以确保它们在输出中的可见性)来调试您所获得的内容。我想到的第一个检查是 MSBuild 任务之后 DependentAssemblies ItemGroup 中实际有什么?
如果您正在做我认为您正在尝试做的事情,即将所有依赖项放入一个目录中,也许是为了部署,那么您是否考虑过让所有项目输出到同一目录? OutDir 和 OutputPath 是您可以使用的两个属性。
Firstly, at what point is it failing? Try debugging what you've got with a few message tasks set to importance="high" (to ensure their visibility in the output). The first check that springs to mind, is what's actually in the DependentAssemblies ItemGroup after the MSBuild task?
If you're doing what I think you're trying to do though, that is, get all dependencies into a single directory, perhaps for deployment, then have you considered instead having all projects output to the same directory? OutDir and OutputPath are two properties you can make use of.