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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/768282/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:23:23  来源:igfitidea点击:

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

visual-studiocommand-linebuild-processpre-build-event

提问by dance2die

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

我正在尝试$(TargetDir)在构建项目之前删除Visual Studio 中的文件。

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

你如何格式化命令行来解决我在下面遇到的这个问题? 替代文字

回答by Eoin Campbell

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) 正在扩展到一个包含文件夹名称中的空格的路径,这破坏了删除命令。

回答by tuck

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)"清理目录。据我所知它正在工作。

回答by jvenema

Try adding quotes around the directory.

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

回答by Václav Dajbych

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

del "$(TargetDir)*.tif"由于目录路径中有空格,您必须写入。

回答by Sudip Shrestha

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 提示“...你确定(Y/N)吗?” 构建不喜欢。

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

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

回答by Meg-90

wmic process where name='chromedriver.exe' delete

wmic进程在哪里 name='chromedriver.exe' delete