1

Does anyone knows how to start a process in "build events" visual studio? for example

TASKKILL /FI "IMAGENAME eq notepad.exe" /F
sleep 3
if $(ConfigurationName)==Debug @echo do some stuff of building and copyng dll files build 
C:\notepad.exe

in the last line, it get stuck and it can't finish to build dll. I try to add ampersand like linux shell to run the process but i didn't have any success.

Carlitos Overflow
  • 609
  • 3
  • 13
  • 41

3 Answers3

2

http://ss64.com/nt/start.html

This "start" command looks promising.

phyatt
  • 18,472
  • 5
  • 61
  • 80
1

If you want your post build event to finish while the application started is still running, you can use cmdow:

C:\Tools\cmdow.exe /Run C:\Windows\notepad.exe

Where C:\Tools\ is the path where you extracted the executable to.

orad
  • 15,272
  • 23
  • 77
  • 113
Gene
  • 4,192
  • 5
  • 32
  • 56
0

You can do this by running your build event in an external script file.*

For example, add this to Post-build event:

powershell.exe -file "$(ProjectDir)Build\Post-build.ps1" -ConfigurationName "$(ConfigurationName)" -PlatformName "$(PlatformName)" -TargetDir "$(TargetDir)"

and create this file under project directory:

Build\Post-build.ps1

param(
    [string]$ConfigurationName,
    [string]$PlatformName,
    [string]$TargetDir
)

#[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
#[void][System.Windows.Forms.MessageBox]::Show("It works.")

Get-Process Notepad | kill
Start-Sleep -seconds 1
if ($ConfigurationName -eq 'Debug')
{
    # Run some debug configuration tasks
}

Start-Process C:\notepad.exe

* Taken from this answer with some modification.

orad
  • 15,272
  • 23
  • 77
  • 113