Visual Studio post build events stuck waiting for executable to finish before running app in debug mode

后端 未结 7 1806
猫巷女王i
猫巷女王i 2020-12-28 15:36

Part of the post build on my project is the execution of a program I wrote for testing the main application. Unfortunately, the post build process in visual studio locks up

相关标签:
7条回答
  • 2020-12-28 15:48

    I uploaded a patch to MSBuild Extension Pack that implements a custom msbuild task called SmartExec that works around this issue.

    http://msbuildextensionpack.codeplex.com/workitem/9053
    http://msbuildextensionpack.codeplex.com/SourceControl/list/patches
    Patch Id 9878

    0 讨论(0)
  • 2020-12-28 15:52

    If you utilize cruise control for your builds, you could place this in the publishers section which allows the build to finish before running the publisher tasks.

    Additionally a custom msbuild task is quite trivial to build, if you know how to spin off a process in .net then it's really simple to do in msbuild. To do this you could edit your .csproj file or your .proj build script to use that custom task.

    using System;
    using Microsoft.Build.Framework;
    using Microsoft.Build.Utilities;
    
    namespace MyTasks
    {
    public class SimpleTask : Task
    {
        public override bool Execute()
        {
    //something involving Process.Start
            return true;
        }
    }
    }
    

    Then in your build script or csproj file you add the using for the task you created and call it.

    0 讨论(0)
  • 2020-12-28 15:54

    I also found that the start trick didn't work and downloading a separate tool to complete such a simple task seemed excessive. After some additional searching I found this SO post which gave an answer that worked for my needs.

    Just replace <actual-command-line-to-run> with your command. Remember to give the full path to the executable and encapsulate it in "quotes" if there's spaces in your path.

    powershell start-process <actual-command-line-to-run>
    
    0 讨论(0)
  • 2020-12-28 15:55

    Wow, seems VS is really stubborn about this.

    You can use this little tool that can launch apps without showing cmd windows (among other things). In your post build event:

    c:\path\to\cmdow /run app.exe
    
    0 讨论(0)
  • 2020-12-28 15:57

    This seems to be a known issue of VS 2010 (e.g. here and here) and it seems it won't be fixed that soon.

    Regarding a possible workaround, similar to the one mentioned by @RichieHindle, one of the MS Connect persons suggests:

    START /WAIT cmd /c YourPostBuildTool.exe
    
    0 讨论(0)
  • 2020-12-28 16:00

    Running your test program via start might work. Change your post build step from this:

    runtest.exe
    

    to this:

    start runtest.exe
    
    0 讨论(0)
提交回复
热议问题