MSBuild-我可以在子目录中编译所有解决方案吗? [英] MSBuild - can I compile all solutions in child directories?
问题描述
MSBuild中是否可以在指定的父项下编译文件夹,子文件夹和sub ...中的所有解决方案?
Is there a way in MSBuild to compile all solutions in folders, and sub-folders, and sub... under a specified parent?
我们的图书馆提供了许多示例程序.我想添加到构建过程中,我们知道它们都可以编译.
We have a bunch of sample programs we ship with our library. I want to add to the build process that we know they all compile.
推荐答案
您可以为restore
和build
操作创建自己的targets
.例如:
You can create own targets
for restore
and build
operations. For example:
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="EntryRestore" DefaultTargets="EntryMSBuild">
<ItemGroup>
<SolutionFile Include="./**/*.sln"/>
</ItemGroup>
<Target Name="EntryRestore">
<Message Text="-----Entry-----" Importance="high"/>
<Message Text=" Restore " Importance="high"/>
<Message Text="-----Entry-----" Importance="high"/>
<MSBuild Projects="%(SolutionFile.Identity)" Targets="restore"/>
</Target>
<Target Name="EntryMSBuild">
<Message Text="-----Entry-----" Importance="high" />
<Message Text=" Build " Importance="high" />
<Message Text="-----Entry-----" Importance="high" />
<MSBuild Projects="%(SolutionFile.Identity)" Targets="build" />
</Target>
</Project>
项SolutionFile
将包含位于当前目录及其子目录中的所有.sln
文件的路径.您也可以在CLI
中定义路径并执行相对路径搜索.
Item SolutionFile
will contains paths for all .sln
files that located in current directory and its subdirectories. You also may define path in CLI
and perform searching relative it.
<ItemGroup>
<SolutionFile Include="$(MyDir)/**/*.sln"/>
</ItemGroup>
MSBuild
任务启动MSBuild
以执行指定的目标.在我们的cas中,它是restore
和build
.该任务使用了"batching
",它允许按元数据遍历项目.
MSBuild
task launches MSBuild
for performing specified targets. In our cas it are restore
and build
. It task used 'batching
' that allow iterate over items by metadata.
&"D:\Visual Studio\MSBuild\15.0\Bin\msbuild.exe" .\Make.targets
MSBuild目标 | 项目元素 | 任务批处理中的项目元数据 | MSBuild任务
MSBuild targets | Item element | Item metadata in task batching | MSBuild task
这篇关于MSBuild-我可以在子目录中编译所有解决方案吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!