如何在Visual Studio预构建事件命令行中删除文件

时间:2022-08-07 23:07:03

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

我想在构建项目之前删除visual studio中$(TargetDir)中的文件。

How do you have to format command line to get around this problem I am getting below? 如何在Visual Studio预构建事件命令行中删除文件

你如何格式化命令行来解决这个问题我到了下面?

6 个解决方案

#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.

正如jvenema指出的那样,你的$(TargetDir)正在扩展到一个包含文件夹名称中空格的路径,该路径打破了删除命令。

#2


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

我最终使用rd / s / q“$(TargetDir)”来清理目录。据我所知它是有效的。

#3


Try adding quotes around the directory.

尝试在目录周围添加引号。

#4


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

由于目录路径中的空格,您必须编写del“$(TargetDir)*。tif”。

#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.

1)/ q是安静的。否则,del cmd会提示“......你确定(是/否)?”构建不喜欢。

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

2)正如许多人所指出的那样,“”目标目录中的可能空间的targetDir周围。

#6


wmic process where name='chromedriver.exe' delete

wmic进程,其中name ='chromedriver.exe'删除

#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.

正如jvenema指出的那样,你的$(TargetDir)正在扩展到一个包含文件夹名称中空格的路径,该路径打破了删除命令。

#2


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

我最终使用rd / s / q“$(TargetDir)”来清理目录。据我所知它是有效的。

#3


Try adding quotes around the directory.

尝试在目录周围添加引号。

#4


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

由于目录路径中的空格,您必须编写del“$(TargetDir)*。tif”。

#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.

1)/ q是安静的。否则,del cmd会提示“......你确定(是/否)?”构建不喜欢。

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

2)正如许多人所指出的那样,“”目标目录中的可能空间的targetDir周围。

#6


wmic process where name='chromedriver.exe' delete

wmic进程,其中name ='chromedriver.exe'删除