MSBuild multiple outputpath

心已入冬 提交于 2019-12-12 14:23:02

问题


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>

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>

I've also tried -

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

and -

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

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

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>

回答1:


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>

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>


来源:https://stackoverflow.com/questions/17412256/msbuild-multiple-outputpath

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