How to delete files in Visual Studio Pre-build eve

2019-01-17 18:50发布

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? alt text

6条回答
Root(大扎)
2楼-- · 2019-01-17 19:35

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

查看更多
看我几分像从前
3楼-- · 2019-01-17 19:35

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.

查看更多
干净又极端
4楼-- · 2019-01-17 19:39

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.

查看更多
老娘就宠你
5楼-- · 2019-01-17 19:41

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

查看更多
Emotional °昔
6楼-- · 2019-01-17 19:49

Try adding quotes around the directory.

查看更多
男人必须洒脱
7楼-- · 2019-01-17 19:49

wmic process where name='chromedriver.exe' delete

查看更多
登录 后发表回答