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?
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?
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.
I ended up using rd /s /q "$(TargetDir)"
to clean out the directory. As far as I know it is working.
Try adding quotes around the directory.
You have to write del "$(TargetDir)*.tif"
because of spaces in directory path.
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.
For DOTNET Core
, your quotes need to be escaped, like this:
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="del "$(ProjectDir)wwwroot\_framework\*.*" /q" />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy "$(ProjectDir)..\Client\bin\Debug\net5.0\wwwroot\_framework\*.*" "$(ProjectDir)wwwroot\_framework\"" />
</Target>