我希望只有在解决方案中的所有Visual Studio项目都编译完成后,才执行此目标。
根据文档
MSBuild 扩展解决方案生成,您可以在与解决方案相同的文件夹中创建一个名为
after.<SolutionName>.sln.targets
的 MSBuild 项目文件。
作为测试,我将以下内容添加到我的 After.Solution.sln.targets 文件中(使用香蕉代替 SomeApplication.exe),并将此文件设置在与我的解决方案文件
.sln
相同的文件夹中:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="PostBuildScript" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
<Message Text="*** BEGIN BANANA ***" Importance="high" />
<Message Text=" _ " Importance="high" />
<Message Text="//\ " Importance="high" />
<Message Text="V \ " Importance="high" />
<Message Text=" \ \_ " Importance="high" />
<Message Text=" \,'.`-. " Importance="high" />
<Message Text=" |\ `. `. " Importance="high" />
<Message Text=" ( \ `. `-. _,.-:\" Importance="high" />
<Message Text=" \ \ `. `-._ __..--' ,-';/" Importance="high" />
<Message Text=" \ `. `-. `-..___..---' _.--' ,'/ " Importance="high" />
<Message Text=" `. `. `-._ __..--' ,' / " Importance="high" />
<Message Text=" `. `-_ ``--..'' _.-' ,' " Importance="high" />
<Message Text=" `-_ `-.___ __,--' ,' " Importance="high" />
<Message Text=" `-.__ `----''' __.-' " Importance="high" />
<Message Text=" `--..____..--' " Importance="high" />
<Message Text="*** END BANANA ***" Importance="high" />
</Target>
</Project>
然后我使用dotnet build
命令来构建它:
dotnet build "xxxx\TestSolutionTarget.sln" --configuration Release --verbosity n
![在此输入图片描述](https://istack.dev59.com/7K7BZ.webp)
在所有 Visual Studio 解决方案项目构建完成之后,此目标将被执行。
或者,您也可以创建一个空项目,引用部分项目并将此目标添加到该空项目中。
希望这可以帮助到您。