我正在尝试创建一个批处理脚本,它将使用Visual Studio 2012的devenv.exe在文件夹中构建所有* .sln文件,我遇到了一些麻烦。使用以下代码我得到“”forfiles“不被视为内部或外部命令......”
我正在从运行Windows 7 Enterprise N 64位的计算机执行此操作。
@echo off
SET executablePath = "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"
SET buildConfig = "Release"
cls
forfiles /m *.sln /c "cmd %executablePath% @file /build %buildConfig%"
答案 0 :(得分:0)
我的批次有点差,但如果您在PC上安装了Powershell,您可以使用以下内容:
$SLNDirectory = "<Path_to_SLN_Files>"
$executablePath = "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"
$buildConfig = "Release"
Clear
$Files = Get-ChildItem $SLNDirectory
Foreach($File in $Files){
$Extension = [System.IO.Path]::GetExtension($File).ToString()
If ($Extension -eq ".sln"){
$theFile = $File.Name
[Array]$SLNFiles +=$theFile
}
}
Foreach($SLNFile in $SLNFiles){
& "$executablePath $SLNFile /build $buildConfig"
}
答案 1 :(得分:0)
试试这个(批处理脚本):
@echo off
SET "executablePath=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"
SET "buildConfig=Release"
cls
for %%i in (*.sln) do cmd /c "%executablePath%" "%%~i" /build %buildConfig%