dotnet-publish.bat 918 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. @echo off
  2. ::启用变量延迟
  3. setlocal EnableDelayedExpansion
  4. echo %~n0.bat start...
  5. ::(x.1)获取basePath
  6. set curPath=%cd%
  7. cd /d "%~dp0"
  8. cd /d ../..
  9. set basePath=%cd%
  10. set publishPath=%basePath%/Publish/release/release/publish
  11. ::(x.2)查找所有需要发布的项目并发布
  12. for /f "delims=" %%f in ('findstr /M /s /i "<publish>" *.csproj') do (
  13. ::get publishName
  14. for /f "tokens=3 delims=><" %%a in ('type "%basePath%\%%f"^|findstr "<publish>.*publish"') do set publishName=%%a
  15. echo publish !publishName!
  16. ::publish
  17. cd /d "%basePath%\%%f\.."
  18. dotnet build --configuration Release
  19. dotnet publish --configuration Release --output "%publishPath%\!publishName!"
  20. @if errorlevel 1 (echo . & echo . & echo 出错,请排查!& pause)
  21. )
  22. ::(x.3)copy bat
  23. xcopy "%basePath%\Publish\ReleaseFile\publish" "%publishPath%" /e /i /r /y
  24. echo %~n0.bat 执行成功!
  25. cd /d "%curPath%"