How to delete files in Visual Studio Pre-build event command line

﹥>﹥吖頭↗ 提交于 2019-11-27 01:43:53

问题


I am trying to delete files in my $(TargetDir) within visual studio before building a project.

How do you have to format command line to get around this problem I am getting below?


回答1:


Try

cd $(TargetDir)
del *.tif

As jvenema pointed out, your $(TargetDir) is expanding into a path containing spaces in the folder names which is breaking the delete command.




回答2:


I ended up using rd /s /q "$(TargetDir)" to clean out the directory. As far as I know it is working.




回答3:


Try adding quotes around the directory.




回答4:


You have to write del "$(TargetDir)*.tif" because of spaces in directory path.




回答5:


Old question but a couple of things:

del "$(TargetDir)*.tif" /q

1) /q is for quiet. Otherwise, del cmd prompts "... Are you sure (Y/N)?" which the build does not like.

2) As many have pointed out, "" around the targetDir for possible space in the target directory.




回答6:


wmic process where name='chromedriver.exe' delete



来源:https://stackoverflow.com/questions/768282/how-to-delete-files-in-visual-studio-pre-build-event-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!