msbuild 通过git生成程序

 

 

#!/bin/sh


echo "test..."
#生成dll的sln
slnDir="/d/xxx/test_renamefile.sln"
#需要修改dll名的工程
file="/d/cxxx/Protocol.aaa.csproj"

test_renamefileOutput="/d/xxxt/sln/bin"
renamefileOutput="/d/xxx/bin"
renamefileFileName="Protocol.aaaa"
msbuildexe="MSBuild.exe"


j=500 #create dll num
for ((i=1; i<=j; i++))
do
    #set file name
    filename=${file##*/}
    array=(${filename//./ })
    targetName="${array[0]}.${array[1]}"
    #replace file
    sed -ri "s|<AssemblyName>.*</AssemblyName>|<AssemblyName>$targetName${i}</AssemblyName>|g" $file
    #rm dir
    echo "reclear dir ${test_renamefileOutput}${i}"
    rm -rf ${test_renamefileOutput}${i}
    echo "reclear dir ${renamefileOutput}${i}"
    rm -rf ${renamefileOutput}${i}
    #build exe
    ${msbuildexe} ${slnDir} -t:Publish -p:Configuration=Release -p:PublishDir=${test_renamefileOutput}${i}
    #copy file 
    echo "copy file...begin,${i}"
    mkdir -p  ${renamefileOutput}${i}/
    cp ${test_renamefileOutput}${i}/${renamefileFileName}${i}.deps.json ${renamefileOutput}${i}/${renamefileFileName}${i}.deps.json
    cp ${test_renamefileOutput}${i}/${renamefileFileName}${i}.pdb ${renamefileOutput}${i}/${renamefileFileName}${i}.pdb
    cp ${test_renamefileOutput}${i}/${renamefileFileName}${i}.dll ${renamefileOutput}${i}/${renamefileFileName}${i}.dll
    cp ${test_renamefileOutput}${i}/${renamefileFileName}${i}.runtimeconfig.json ${renamefileOutput}${i}/${renamefileFileName}${i}.runtimeconfig.json
    #cp ${test_renamefileOutput}${i}/${renamefileFileName}${i}.runtimeconfig.dev.json ${renamefileOutput}${i}/${renamefileFileName}${i}.runtimeconfig.dev.json
    echo "copy file...success,${i}"
done

 

posted @ 2022-10-31 10:15  bleach3  阅读(44)  评论(0编辑  收藏  举报