问题
I have something like the following in the .csproj file for an ASP.NET MVC 4 project in Visual Studio 2012:
<Target Name="AfterBuild">
<CallTarget Targets="InstallBuildDependencies" />
<CallTarget Targets="BuildAssets" />
</Target>
<Target Name="InstallBuildDependencies">
<Message Text="Installing build dependencies:" Importance="high" />
<Exec Command="npm install" />
</Target>
<Target Name="BuildAssets">
<Message Text="Building assets:" Importance="high" />
<Exec Command="grunt build" />
</Target>
and something like this in a .pubmxl for the same project:
<PropertyGroup>
<!-- Other properties here -->
<InstallBuildDependenciesCmd>npm install</InstallBuildDependenciesCmd>
<BuildDistAssetsCmd>grunt dist</BuildDistAssetsCmd>
<PipelineDependsOn>
InstallBuildDependencies;
BuildDistAssets;
</PipelineDependsOn>
</PropertyGroup>
<Target Name="InstallBuildDependencies">
<Message Text="Installing build dependencies:" Importance="high" />
<Exec Command="$(InstallBuildDependenciesCmd)" />
</Target>
<Target Name="BuildDistAssets" AfterTargets="InstallBuildDependencies">
<Message Text="Building distribution assets:" Importance="high" />
<Exec Command="$(BuildDistAssetsCmd)" />
</Target>
The issue is that, in the first snippet, none of the messages or output from the commands displays in the Ouput console in Visual Studio until everything in the build has finished. This is not ideal since it would be better to see the messages and command output in "real-time".
In the second snippet, both the messages and command output DO show in "real-time" in the Output console.
Is it possible to get the messages from the first first snippet to display in real-time like the messages in the second snippet do? Why am I experiencing this inconsistency?
回答1:
Try use DependsOnTargets
instead of CallTarget
:
<Target Name="AfterBuild" DependsOnTargets="InstallBuildDependencies,BuildAssets">
</Target>
回答2:
Super late answer, but recently stumbled with this same issue. It seems that this is not possible, according to the Exec Task documentation in the Remarks section:
However, the Exec task, unlike a more specific task, cannot gather output from the tool or command that it runs.
Hope this saves some time for anyone else.
来源:https://stackoverflow.com/questions/38125377/msbuild-afterbuild-messages-not-showing-real-time