40.Station-publish.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. set -e
  2. #---------------------------------------------------------------------
  3. #(x.1)参数
  4. args_="
  5. export basePath=/root/temp/svn
  6. export _nugetPath=$basePath/Publish/release/.nuget
  7. # "
  8. if [ ! $_nugetPath ]; then _nugetPath=$basePath/Publish/release/.nuget; fi
  9. #----------------------------------------------
  10. echo "(x.2)获取netVersion"
  11. netVersion=`grep '<TargetFramework>' $(grep '<publish>' ${basePath} -r --include *.csproj -l | head -n 1) | grep -oP '>(.*)<' | tr -d '<>'`
  12. publishPath=$basePath/Publish/release/release/Station\($netVersion\)
  13. echo publish Station
  14. echo dotnet version: $netVersion
  15. #----------------------------------------------
  16. echo "(x.3)查找所有需要发布的项目并发布"
  17. mkdir -p $publishPath
  18. docker run -i --rm \
  19. --env LANG=C.UTF-8 \
  20. -v $_nugetPath:/root/.nuget \
  21. -v $basePath:/root/code \
  22. serset/dotnet:sdk-6.0 \
  23. bash -c "
  24. set -e
  25. basePath=/root/code
  26. publishPath=\$basePath/Publish/release/release/Station\($netVersion\)
  27. #(x.3)查找所有需要发布的项目并发布
  28. cd \$basePath
  29. for file in \$(grep -a '<publish>' . -rl --include *.csproj)
  30. do
  31. cd \$basePath
  32. #get publishName
  33. publishName=\`grep '<publish>' \$file -r | grep -oP '>(.*)<' | tr -d '<>'\`
  34. echo publish \$publishName
  35. #publish
  36. cd \$(dirname \"\$file\")
  37. dotnet build --configuration Release
  38. dotnet publish --configuration Release --output \"\$publishPath/\$publishName\"
  39. #copy xml
  40. for filePath in bin/Release/$netVersion/*.xml ; do \\cp -rf \$filePath \"\$publishPath/\$publishName\";done
  41. done
  42. #(x.4)copy dir
  43. \cp -rf \$basePath/Publish/ReleaseFile/Station/. \"\$publishPath\"
  44. #(x.5)copy ServiceCenter
  45. mkdir -p \"\$basePath/Publish/release/release/ServiceCenter($netVersion)\"
  46. \cp -rf \$publishPath/ServiceCenter/. \"\$basePath/Publish/release/release/ServiceCenter($netVersion)/ServiceCenter\"
  47. \cp -rf \"\$publishPath/01.ServiceCenter.bat\" \"\$basePath/Publish/release/release/ServiceCenter($netVersion)\"
  48. \cp -rf \"\$publishPath/01.Start-4580.bat\" \"\$basePath/Publish/release/release/ServiceCenter($netVersion)\"
  49. "
  50. echo 'publish succeed!'