MSBuild多个输出路径 [英] MSBuild multiple outputpath

查看:111
本文介绍了MSBuild多个输出路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到 this SO问题,并有类似的要求.这就是我在.targets文件中拥有的-

I saw this S.O question and have a similar requirement. This is what I have in a .targets file -

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup Condition="$(TeamBuildOutDir) != '' ">
        <OutputPath>$(TeamBuildOutDir)\Assemblies</OutputPath>                 
    </PropertyGroup>

如何输出到多个文件夹? 例如-$(TeamBuildOutDir)\ Assemblies2

How can I output to multiple folders? e.g.- $(TeamBuildOutDir)\Assemblies2

TIA

谢谢尼克,复制/粘贴把它弄糊了.这就是我尝试过的-

Thanks Nick, The copy/paste mucked it up. This is what I tried -

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="$(TeamBuildOutDir) != '' ">
 <OutputPath>$(TeamBuildOutDir)\Assemblies</OutputPath>                   
</PropertyGroup>
<Target Name="AfterBuild">
 <Copy SourceFiles="$(OutputPath)\**\*.*" DestinationFolder="$(TeamBuildOutDir)\Assemblies2" />
</Target>
</Project>

我也尝试过-

 <Copy SourceFiles="$(OutputPath)\***\*.*" DestinationFolder="$(TeamBuildOutDir)\Assemblies2" />

和-

 <Copy SourceFiles="$(OutputPath)\***\*.*" DestinationFolder="$(TeamBuildOutDir)\" />

如果目录不存在导致出现问题,但仍然没有运气.

in case the directory not being present caused an issue but still no luck.

更新7/28.尝试过此操作,但仍无法正常工作(没有错误,但输出目录中不存在文件.它们存在于Assemblies文件夹中,因此我知道目标文件已被触发.)-

Updated 7/28. Tried this but doesn't work still (no errors but the files are not present in the output directory. They are present in the Assemblies folder so I know the targets file is being triggered.) -

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="$(TeamBuildOutDir) != '' ">
 <OutputPath>$(TeamBuildOutDir)\Assemblies</OutputPath>                   
</PropertyGroup>
<Target Name="AfterBuild">
 <CreateItem Include="$(OutputPath)\**\*.*">
     <Output ItemName="Outfiles" TaskParameter="Include" />
 </CreateItem>
 <Copy SourceFiles="@(Outfiles)" DestinationFiles="@(Outfiles->'$(TeamBuildOutDir)\%(relativedir)%(Filename)%(Extension)')" SkipUnchangedFiles="false" />
</Target>
</Project>

推荐答案

您将创建一个AfterBuild目标,该目标的复制任务是将$(OutputPath)的内容复制到$(TeamBuildOutDir)\ Assemblies2.

You create an AfterBuild target with a copy task the contents of $(OutputPath) to $(TeamBuildOutDir)\Assemblies2.

<Target Name="AfterBuild">
 <Copy SourceFiles="$(OutputPath)\**\*.*" DestinationFolder="$(TeamBuildOutDir)\Assemblies2" />
</Target>

编辑,对其进行更新以包括测试消息,并包括"DependsOnTarget"属性,以查看是否可以在构建过程之后进行此操作...

Edit, updating this to include a test message, and include a "DependsOnTarget" attribute to see if we can get this to occur after the build process...

<Target Name="AfterBuild" DependsOnTarget="Build">
 <Message Text="**** TEST **** " Importance="high" />
 <Copy SourceFiles="$(OutputPath)\**\*.*" DestinationFolder="$(TeamBuildOutDir)\Assemblies2" />
</Target>

这篇关于MSBuild多个输出路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆