Visual studio 2012 在文件夹中生成所有解决方案
我正在尝试创建一个批处理脚本,该脚本将使用Visual Studio 2012的devenv.exe在文件夹中生成所有*.sln文件,我遇到了一些问题。使用以下代码,我得到的forfiles不被识别为内部或外部命令 我正在运行Windows7EnterpriseN64位的计算机上执行此操作Visual studio 2012 在文件夹中生成所有解决方案,visual-studio-2012,batch-file,Visual Studio 2012,Batch File,我正在尝试创建一个批处理脚本,该脚本将使用Visual Studio 2012的devenv.exe在文件夹中生成所有*.sln文件,我遇到了一些问题。使用以下代码,我得到的forfiles不被识别为内部或外部命令 我正在运行Windows7EnterpriseN64位的计算机上执行此操作 @echo off SET executablePath = "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.
@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%"
我的批处理有点差,但如果您的电脑上安装了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"
}
尝试以下批处理脚本:
@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%
这可能会奏效。我试图使用批处理文件,因为某些开发人员计算机显然没有Powershell或至少没有设置文件关联。您可以使用assoc命令更改文件关联:assoc.ps1=C:\Windows\System32\windowspowshell\v1.0\Powershell.exe,然后查看是否可以运行.ps1文件。虽然Assoc需要以管理员权限从命令提示符运行。只要操作系统是Windows Vista或更高版本,就应该安装Powershell。如果他们有XP,它可以安装,但可能不值得从它的声音的努力。