我需要创建一个批处理脚本:
- git签出一个分支
- git拉它
- 构建C#解决方案
- 将生成的C#解决方案存储在用户指定的位置
我已经完成了步骤1和2,它们运行良好。我在第3步和第4步遇到问题。我该怎么做?我有文件";Automated_Test_Recorder.sln";。
批处理脚本应该创建一个名为"的文件夹;Automated_Test_Recorder";内置解决方案。
我看到了一些关于使用msbuild的内容,但我尝试过,它似乎没有被识别。有没有其他选择,因为如果另一个用户运行我的批处理脚本,如果他们没有msbuild,它将不起作用。
我正在使用以下脚本重建我的一个解决方案:
:: find Visual Studio installation directory
:: requires vswhere to be on the PATH
:: typical "C:Program Files (x86)Microsoft Visual StudioInstallervswhere.exe"
:: cf. https://github.com/microsoft/vswhere
for /f "usebackq tokens=1* delims=: " %%i in (`vswhere -latest -requires Microsoft.Component.MSBuild`) do (
if /i "%%i"=="installationPath" set InstallDir=%%j
)
:: https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-command-line-reference?view=vs-2019
echo InstallDir=%InstallDir%
if exist "%InstallDir%MSBuildCurrentBinMSBuild.exe" (
"%InstallDir%MSBuildCurrentBinMSBuild.exe" -nologo -verbosity:normal akFortune.sln -property:Configuration=Release
) else (
echo.
echo MSBuild not found!
echo expected in "%InstallDir%MSBuildCurrentBinMSBuild.exe"
echo.
goto xit
)