40.dotnet-publish.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. set -e
  2. #---------------------------------------------------------------------
  3. #(x.1)参数
  4. args_="
  5. export codePath=/root/temp/svn
  6. # "
  7. #----------------------------------------------
  8. echo "(x.2)dotnet-publish"
  9. echo "dotnet version: ${netVersion}"
  10. mkdir -p $codePath/Publish/release/release/publish
  11. docker run -i --rm \
  12. --env LANG=C.UTF-8 \
  13. -v $codePath:/root/code \
  14. serset/dotnet:6.0-sdk \
  15. bash -c "
  16. set -e
  17. basePath=/root/code
  18. publishPath=\$basePath/Publish/release/release/publish
  19. #(x.3)查找所有需要发布的项目并发布
  20. cd \$basePath
  21. for file in \$(grep -a '<publish>' . -rl --include *.csproj)
  22. do
  23. cd \$basePath
  24. #get publishName
  25. publishName=\`grep '<publish>' \$file -r | grep -oP '>(.*)<' | tr -d '<>'\`
  26. echo publish \$publishName
  27. #publish
  28. cd \$(dirname \"\$file\")
  29. dotnet build --configuration Release
  30. dotnet publish --configuration Release --output \$publishPath/\$publishName
  31. done
  32. "
  33. #(x.4)copy bat
  34. \cp -rf $codePath/Publish/ReleaseFile/publish/. $codePath/Publish/release/release/publish
  35. echo 'publish succeed!'