如何使用for循环在批处理文件中回显参数

时间:2019-05-20 17:48:04

标签: cmd msbuild

我的批处理文件的某些参数被回显,而其他参数则没有。我想在echo语句中看到解决方案文件的名称,以及正在构建的解决方案的名称。

这是我的批处理文件的内容

uris = ["https://www.website.com/colors/blue?src=camp_id1&gclid=Cj0KCQjwoInnBRDDARIsANBVyASfVUCg4ShKaAq4q8cX6xgB4kYj-oRGEPuO5UuUaAnZi2zD7yQU684aAo3KEALw_wcB",
"https://www.website.com/colors/blue?gclid=Cj0KCQjwoInnBRDDARIsANBVyASfVUCg4ShKaAq4q8cX6xgB4kYj-oRGEPuO5UuUaAnZi2zD7yQU684aAo3KEALw_wcB&src=camp_id1",
"https://www.website.com/colors/blue?page=2&gclid=Cj0KCQjwoInnBRDDARIsANBVyASfVUCg4ShKaAq4q8cX6xgB4kYj-oRGEPuO5UuUaAnZi2zD7yQU684aAo3KEALw_wcB&src=camp_id1",
"https://www.website.com/colors/blue?page=2&src=camp_id1"
]

uris.map do |s| 
  uri = URI.parse(s)
  query_params = uri.query.scan(/\w+(?==)[^&]*/).reject{|s| s.start_with?('gclid')}
  uri.query = query_params.empty? ? nil : query_params.join('&')
  uri.to_s
end

# => ["https://www.website.com/colors/blue?src=camp_id1", 
#     "https://www.website.com/colors/blue?src=camp_id1", 
#     "https://www.website.com/colors/blue?page=2&src=camp_id1",  
#     "https://www.website.com/colors/blue?page=2&src=camp_id1"]

注意: 我知道解决方案文件名已经设置好了,因为它已经建立了!

我不确定的另一件事是在for循环中将解决方案文件名重置为空字符串...这是必需的吗?

这是我得到的输出:

echo on

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"

set _SCRIPT_DRIVE=%~d0
echo DRIVE %_SCRIPT_DRIVE%

set baseDir=%_SCRIPT_DRIVE%\Source\Service\4.0\Branches\ARES
echo baseDir =  %baseDir%

set buildLog=%baseDir%\Build.log
echo deleting build log: %buildLog%
del %buildLog%

set thirdParty=Cert,MDTE
echo.
echo building  %thirdParty%
echo.

for %%p in (%thirdParty%) do (
  echo.
  echo building %%p

  cd %%p

  set thirdPartySolutionFile=%%p%.sln
  echo solution file : %thirdPartySolutionFile%

  MSBuild %thirdPartySolutionFile% /t:Rebuild /m /p:Configuration=Debug >> %buildLog%

  rem Is this necessary?
  set thirdPartySolutionFile=

  cd ..
)

exit /B

我希望在输出中看到解决方案文件名以及正在生成的内容,例如:

F:\Source\Service\4.0\branches\ARES>RebuildAll.bat

F:\Source\Service\4.0\branches\ARES>echo on

F:\Source\Service\4.0\branches\ARES>call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
DRIVE F:
baseDir =  F:\Source\Service\4.0\Branches\ARES
here is build log: F:\Source\Service\4.0\Branches\ARES\Build.log

building  Cert,MDTE


building Cert
solution file :

building MDTE
solution file :

F:\Source\Service\4.0\branches\ARES>

0 个答案:

没有答案