1

I've upgraded to a new windows 10 development machine.

Everything works great, except post-build events in msbuild/visual studio. This is for any project, new or existing. They all work fine on other people's windows 7 machines. They work fine on the build server (jenkins).

They do not work for me at all, either in visual studio or with msbuild. PRE-build events works fine. It's like the postbuild event isn't even defined.

Unfortunately, our postbuild events are fundamental to the build process.

Starting with a basic console app and configuring the build events as:

<PropertyGroup>
  <PreBuildEvent>echo before build</PreBuildEvent>
</PropertyGroup>
<PropertyGroup>
  <PostBuildEvent>echo after build</PostBuildEvent>
</PropertyGroup>

The build output is literally:

1>------ Rebuild All started: Project: ConsoleApplication1, Configuration: Debug Any CPU ------
1>  before build
1>  ConsoleApplication1 -> C:\dev\postbuild\ConsoleApplication1\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

Running msbuild with /v:diag I get this section:

PostBuildEvent = echo after build
PostBuildEventDependsOn = 
PreBuildEvent = echo before build
PreBuildEventDependsOn = 

When running prebuild:

Target "PreBuildEvent: (TargetId:22)" in file "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets" from project "c:\dev\postbuild\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.csproj" (target "CoreBuild" depends on it):
Using "Exec" task from assembly "Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "Exec" (TaskId:19)
  Task Parameter:WorkingDirectory=bin\Debug\ (TaskId:19)
  Task Parameter:Command=echo before build (TaskId:19)
  echo before build (TaskId:19)
  before build (TaskId:19)
Done executing task "Exec". (TaskId:19)
Done building target "PreBuildEvent" in project "ConsoleApplication1.csproj".: (TargetId:22)

When running PostBuild:

Target "PostBuildEvent: (TargetId:77)" in file "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets" from project "c:\dev\postbuild\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.csproj" (target "CoreBuild" depends on it):
Done building target "PostBuildEvent" in project "ConsoleApplication1.csproj".: (TargetId:77)
Jim T
  • 12,336
  • 5
  • 29
  • 43
  • 3
    No idea why it won't run, might be a bug, but PostBuildEvent has some disadvantages (runs only batch file code, can be overriden) so the alternative is usually more interesting and happens to solve your problem as well: ` ` – stijn Feb 22 '17 at 11:17
  • 1
    The Target does work around the problem nicely. Still annoyed as to why it doesn't work in the first place. – Jim T Feb 22 '17 at 12:26
  • If you know the basics of msbuild I'd suggest to look for the string `PostBuildEvent` in all files under C:\Program Files (x86)\MSBuild (or wherever it's located for Windows 10), that should give insight into why it is ignored. – stijn Feb 22 '17 at 13:48
  • Post build event is works fine on my Windows 10 with Visual Studio 2015 update 3, which version of Visual Studio you are using? Have you try to set “Always” in the “Run the post-build event”? If this issue is still persist, Could you please share us a sample or detail steps to reproduce this issue? You can accept Stijn`s suggestion:” ” as temporary workaround before this issue be solved. – Leo Liu Feb 23 '17 at 05:50
  • Using the `` has worked around the issue for me for now. The postbuild events are set to running "On Successful build" in the example output. For a reproduction, it's simply a bog-standard console app with the postbuilds set as described in the question. No-one else can reproduce this in the office. The only difference is that I'm on windows 10. I'm running V 14.0.25431.01 Update 3 Whether is set post-build events to `Always`, `On Successful build` or `When the build updates the project output` has no bearing on the result. – Jim T Feb 27 '17 at 10:46
  • I have tested it on the Windows 10 10.0.14393 & 10.0.10240, but could not reproduced this issue.So strange. Could you please try to repair your Visual Studio, configure with other the build events etc. Besides, have you try this in other version Visual Studio on same PC? – Leo Liu Feb 28 '17 at 09:43
  • Same thing for me, Windows 10 and VS 2015. Out of nowhere, PostBuild events didn't fire anymore. Using – Francesco B. Apr 01 '20 at 15:50

0 Answers0