简体   繁体   中英

Install and Uninstall Your Windows Service Using Pre-build and Post-Build Events

I have these scripts in pre-build and post-build events of visual studio for uninstalling and installing windows service

%WinDir%\Microsoft.NET\Framework\v4.0.30319\installutil /u "$(TargetPath)"

%WinDir%\Microsoft.NET\Framework\v4.0.30319\installutil "$(TargetPath)"

When I build first time it works;

When I rebuild, I get this file not found exception System.IO.FileNotFoundException : Could not load file or assembly ' file:///C:\\Projects\\DeviceManagement.ServiceHost\\bin\\Debug\\DeviceManagement.ServiceHost.exe ' or one of its dependencies. The system cannot find the file specified..

I can see this exe file in my debug folder though.

Rebuild does a clean, so it makes sense that the output isn't going to be there on pre-build. No need to do anything in the pre-build event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM