我有大约80个控制台应用程序,我想构建并输出到保存目录下的单独目标目录。
c:\builds
/App1
/App2
/app3
这个脚本执行大规模构建,但我似乎无法将完成的输出从release目录复制到目标目录,也不能直接在那里发送输出。
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Solution Include="./**/*.sln">
<Properties>Configuration=Release;Platform=Any CPU</Properties>
</Solution>
<MyReleaseFiles Include=".\bin\release\*.*" Exclude=".\bin\release\*vshost.exe" />
</ItemGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<MyReleaseOutput>.\release</MyReleaseOutput>
<OutputPath>c:\builds\$(AssemblyName)\</OutputPath>
<OutDir>$(OutputPath)</OutDir>
</PropertyGroup>
<Target Name="Build">
<MSBuild Projects="@(Solution)" BuildInParallel="true" Targets="Build" />
<MakeDir Directories="$(OutputPath)" />
<Copy SourceFiles="@(MyReleaseFiles)" DestinationFolder="$(OutputPath)" />
</Target>
</Project>
答案 0 :(得分:1)
使用MSBuild构建多个解决方案并将应用程序复制到单独的文件夹
正如stijn所说“必须在构建项目的项目中设置OutputPath,只有它可以在项目的上下文中评估$(AssemblyName)。”,所以我们不能直接从项目文件中使用它。
作为一种变通方法,您可以将ItemGroup
与Subfolder
用于每个项目:
<ItemGroup>
<Projects Include="project1.csproj" />
<Subfolder>project1</Subfolder>
<Projects Include="project2.csproj" />
<Subfolder>project2</Subfolder>
<Projects Include="project3.csproj" >
<Subfolder>project3</Subfolder>
</Projects>
</ItemGroup>
然后对每个OutputPath使用%(Projects.Subfolder)
:
<Target Name="_BuildSingleConfiguration">
<MSBuild Projects="@(Projects)"
BuildInParallel="true"
Properties="Configuration=$(Configuration);OutputPath=%(Projects.BuildOutputPath)\%(Projects.Subfolder)" />
</Target>
认证:How to give a different OutputPath per project per build configuration with MSBuild?
希望这有帮助。