gpt4 book ai didi

.net - 你如何在 MSBuild 中递归调用任务?

转载 作者:行者123 更新时间:2023-12-02 02:37:54 24 4
gpt4 key购买 nike

例如我想每次调用这些脚本传递 diff 参数:

<ItemGroup> 
<SqlFiles Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\Tables\*.sql" />
<SqlFiles Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\Functions\*.sql" />
<SqlFiles Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\Views\*.sql" />
<SqlFiles Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\ForeignKeys\*.sql" />
<SqlFiles Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\StoredProcedures\*.sql" />
<SqlFiles Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\Data\*.sql" />
</ItemGroup>

最佳答案

您可以通过使用带有PropertiesMSBuild Task 来做到这一点。

<!-- Dont itemize sql files now, if you want to differenciate the task operations -->
<ItemGroup>
<SqlDirs Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\Tables" />
<SqlDirs Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\Functions" />
<SqlDirs Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\Views" />
<SqlDirs Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\ForeignKeys" />
<SqlDirs Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\StoredProcedures" />
<SqlDirs Include="$(SourceServicesDbSqlRootDir)CreateScripts\$(SourceServiceName)\Data" />
</ItemGroup>


<Target Name="MainTask">
<MSBuild Projects="$(MSBuildProjectFile)"
Properties="SqlDir=%(SqlDirs.Fullpath)"
Targets="RecursivelyCalledTask">
<Output ItemName="ProjSources" TaskParameter="TargetOutputs"/>
</MSBuild>
</Target>

<Target Name="RecursivelyCalledTask">
<!-- We create here the SqlFiles items based on SqlDir-->
<CreateItem Include="$(SqlDir)\*.sql">
<Output ItemName="SqlFiles" TaskParameter="Include"/>
</CreateItem>

<Message Text="SqlFiles -> @(SqlFiles)"/>
</Target>

关于.net - 你如何在 MSBuild 中递归调用任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/556449/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com