使用PowerShell和UNC路径清除NMAKE

时间:2014-03-08 14:24:14

标签: c powershell makefile nmake

尝试使用NMAKE,PowerShell和UNC路径清理当前版本时遇到一些问题。在nmakefile中,我的clean目标如下所示:

clean: del obj\* /Q

键入“nmake clean”时,应该删除“obj”目录中的所有文件。但是,它不起作用。我收到以下错误:

CMD.exe was started with the specified path
UNC paths are not supported
Using the Windows directory instead
System cannot find the specified file
NMAKE : fatal error U1077: 'del' : return code '0x1'

真的?它会回到Windows目录吗?感谢上帝,我没有

del *

在干净的目标中。在最初的冲击(以及我没有使用上述命令的解脱)之后,我试图找到另一种从nmakefile清理我的“obj”目录的方法。我尝试使用PowerShell命令而不是“del”,即像这样:

clean: Remove-Item obj/* -Recurse -Force

然而,这仍然不起作用。 NMAKE仍在尝试启动CMD.exe,然后从那里运行“Remove-Item”,当然这不起作用。而且它仍然会做这个“回退到Windows目录 - 在案例中的UNC路径”的恐怖!

有人能告诉我我应该如何实现一个适用于PowerShell和UNC路径的nmake clean目标?

另外,有没有办法关闭这个落后到Windows目录的恐怖?

谢谢!

1 个答案:

答案 0 :(得分:1)

似乎nmake对PowerShell没有本机支持,因此您需要使用参数运行PowerShell.exe,如下所示:

clean: powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "Remove-Item obj/* -Recurse -Force"

如果出现任何问题,请先尝试使用无害的东西:

clean: powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "Get-ChildItem /* -Recurse -Force"
相关问题