40.Station-publish.bat 1.6 KB

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