如何在MSBuild ItemGroups的「循環」中執行EXEC任務?如何在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任務。
我的答案,這已被刪除,但我想說明的記錄,我的體驗,因爲寫這個問題讓我非常強烈地感覺到這是一個糟糕的主意:你應該使用像Psake或gulp這樣的工具來做這樣的事情。 – 2015-06-09 14:37:58