40.Station-publish.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. set -e
  2. #---------------------------------------------------------------------
  3. # args
  4. args_="
  5. export basePath=/root/temp/svn
  6. export NUGET_PATH=$basePath/Publish/release/.nuget
  7. # "
  8. if [ ! $NUGET_PATH ]; then NUGET_PATH=$basePath/Publish/release/.nuget; fi
  9. #----------------------------------------------
  10. echo "#40.Station-publish.sh -> find projects and build"
  11. export devOpsPath="$PWD/.."
  12. docker run -i --rm \
  13. --env LANG=C.UTF-8 \
  14. -v $NUGET_PATH:/root/.nuget \
  15. -v "$basePath":/root/code \
  16. -v "$basePath":"$basePath" \
  17. serset/dotnet:sdk-6.0 \
  18. bash -c "
  19. set -e
  20. cd /root/code
  21. if grep '<publish>' -r --include *.csproj; then
  22. echo '#40.Station-publish.sh -> got projects need to be built'
  23. else
  24. echo '#40.Station-publish.sh -> skip for no project needs to be built'
  25. exit 0
  26. fi
  27. echo '#1 get netVersion'
  28. export netVersion=\$(grep '<TargetFramework>' \$(grep '<publish>' -rl --include *.csproj | head -n 1) | grep -oP '>(.*)<' | tr -d '<>')
  29. echo netVersion: \$netVersion
  30. export basePath=/root/code
  31. export publishPath=/root/code/Publish/release/release/Station\(\$netVersion\)
  32. mkdir -p \$publishPath
  33. echo '#2 publish station'
  34. for file in \$(grep -a '<publish>' . -rl --include *.csproj)
  35. do
  36. # get publishName
  37. cd /root/code
  38. publishName=\`grep '<publish>' \$file -r | grep -oP '>(.*)<' | tr -d '<>'\`
  39. echo publish \$publishName
  40. # publish
  41. cd \$(dirname \"\$file\")
  42. dotnet build --configuration Release
  43. dotnet publish --configuration Release --output \"\$publishPath/\$publishName\"
  44. # copy xml
  45. for filePath in bin/Release/\$netVersion/*.xml ; do \\cp -rf \$filePath \"\$publishPath/\$publishName\";done
  46. done
  47. #3 copy station release files
  48. if [ -d \"/root/code/Publish/ReleaseFile/Station\" ]; then
  49. echo '#3 copy station release files'
  50. \cp -rf /root/code/Publish/ReleaseFile/Station/. \"\$publishPath\"
  51. fi
  52. #4 copy extra release files
  53. bashFile=\"$devOpsPath/../environment/build-bash__40.Station-publish__#4_copyExtraReleaseFiles.sh\"
  54. if [ -f \"\$bashFile\" ]; then
  55. echo '#4 copy extra release files'
  56. sh \"\$bashFile\"
  57. fi
  58. "
  59. echo '#40.Station-publish.sh -> success!'