Ibz*_*Ibz 0 c# msbuild csproj msbuild-target visual-studio-2017
我已将AfterBuild目标添加到Visual Studio项目,这是包含多个Visual Studio项目的解决方案的一部分。
解决方案设置示例
例子.sln
ExampleProj.csproj
ExampleProj.Test.csproj
目标示例:
<Target Name="PostBuildScript" AfterTargets="AfterBuild" Condition="'$(Configuration)' == 'Release'">
<PropertyGroup>
<BuildCommand>"SomeApplication.exe")</BuildCommand>
</PropertyGroup>
<Exec Command="$(BuildCommand)" ConsoleToMSBuild="true" LogStandardErrorAsError="true" WorkingDirectory="$(ProjectDir)" />
</Target>
Run Code Online (Sandbox Code Playgroud)
我希望此目标仅在解决方案中的所有Visual Studio项目都已建立之后才能执行。
有没有办法实现这一目标。
注意:dotnet build在Visual Studio中使用和生成命令时,我的行为必须相同。
我希望此目标仅在解决方案中的所有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>
Run Code Online (Sandbox Code Playgroud)
然后用dotnet build命令构建它:
dotnet build "xxxx\TestSolutionTarget.sln" --configuration Release --verbosity n
Run Code Online (Sandbox Code Playgroud)
在解决方案中的所有 Visual Studio项目均已构建之后,将执行此目标。
或者,您也可以创建单独的空项目,引用所有项目的子集,然后将此目标添加到空项目中。
希望这可以帮助。
| 归档时间: |
|
| 查看次数: |
1392 次 |
| 最近记录: |