MSBuild 将依赖项项目的输出复制到另一个文件夹中

发布于 2024-11-27 16:50:27 字数 878 浏览 0 评论 0原文

我有一个项目有几个项目依赖项,我想将两个依赖项目的输出(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技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

英雄似剑 2024-12-04 16:50:27

首先,它在什么时候失败了?尝试将一些消息任务设置为重要性=“高”(以确保它们在输出中的可见性)来调试您所获得的内容。我想到的第一个检查是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文