sers-publish(net6.0).bat 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. @echo off
  2. ::启用变量延迟
  3. setlocal EnableDelayedExpansion
  4. ::(x.1)初始化
  5. set netVersion=net6.0
  6. echo publish sers
  7. echo dotnet version: %netVersion%
  8. ::(x.2)获取basePath
  9. set curPath=%cd%
  10. cd /d "%~dp0"
  11. cd /d ../..
  12. set basePath=%cd%
  13. set publishPath=%basePath%/Publish/release/Sers/SersPublish/%netVersion%
  14. ::修改要发布项目的netcore版本号为net6.0
  15. Publish\cmd\VsTool.exe replace -r --path "%basePath%" --file "App.Gateway.csproj|App.Gover.Gateway.csproj|App.ServiceCenter.csproj|Did.SersLoader.Demo.csproj|App.Robot.Station.csproj" --old "<TargetFramework>netcoreapp2.1</TargetFramework>" --new "<TargetFramework>net6.0</TargetFramework>"
  16. ::(x.3)查找所有需要发布的项目并发布
  17. for /f "delims=" %%f in ('findstr /M /s /i "<publish>" *.csproj') do (
  18. ::get name
  19. for /f "tokens=3 delims=><" %%a in ('type "%basePath%\%%f"^|findstr "<publish>.*publish"') do set name=%%a
  20. echo publish !name!
  21. ::publish
  22. cd /d "%basePath%\%%f\.."
  23. dotnet build --configuration Release
  24. dotnet publish --configuration Release --output "%publishPath%\!name!"
  25. @if errorlevel 1 (echo . & echo . & echo 出错,请排查!& pause)
  26. ::copy xml
  27. xcopy "bin\Release\%netVersion%\*.xml" "%publishPath%\!name!" /i /r /y
  28. )
  29. ::(x.4)copy bat
  30. xcopy "%basePath%\Publish\PublishFile\SersPublish" "%publishPath%" /e /i /r /y
  31. ::还原项目的版本号
  32. cd /d "%basePath%"
  33. Publish\cmd\VsTool.exe replace -r --path "%basePath%" --file "App.Gateway.csproj|App.Gover.Gateway.csproj|App.ServiceCenter.csproj|Did.SersLoader.Demo.csproj|App.Robot.Station.csproj" --old "<TargetFramework>net6.0</TargetFramework>" --new "<TargetFramework>netcoreapp2.1</TargetFramework>"
  34. echo %~n0.bat 执行成功!
  35. cd /d "%curPath%"