如何在MSBuild ItemGroups中对“EXEC”任务执行“循环”操作?
而不是像下面这样一遍又一遍地重复此命令:
<Exec ContinueOnError="false" Command="sqlcmd -S $(ServerName) $(SqlServerUser) -d $(DbName) -v TableName=%22account%22 -i data\add_sql_cache.sql -b" />
<Exec ContinueOnError="false" Command="sqlcmd -S $(ServerName) $(SqlServerUser) -d $(DbName) -v TableName=%22services%22 -i data\add_sql_cache.sql -b" />
<Exec ContinueOnError="false" Command="sqlcmd -S $(ServerName) $(SqlServerUser) -d $(DbName) -v TableName=%22servicesGroup%22 -i data\add_sql_cache.sql -b" />
<Exec ContinueOnError="false" Command="sqlcmd -S $(ServerName) $(SqlServerUser) -d $(DbName) -v TableName=%22servicesCategory%22 -i data\add_sql_cache.sql -b" />
我更想定义一个ItemGroup,然后执行一个“循环”。 我已经定义好了ItemGroup:
<ItemGroup>
<CachedTables Include="account" />
<CachedTables Include="services" />
<CachedTables Include="servicesGroup" />
<CachedTables Include="servicesCategory" />
但由于MSBuild令人难以理解的语法,我不知道如何在循环中执行带有上述ItemGroup作为输入的Exec任务。