• 开发常用脚本 -- 自动下载nuget及引用的包,并编译项目的脚本


    创建编写 build.sh 脚本文件,内容如下:

    #!/usr/bin/env bash
    #
    # Generated by: https://github.com/swagger-api/swagger-codegen.git
    #
    
    frameworkVersion=net40
    
    # sdk must match installed framworks under PREFIX/lib/mono/[value]
    sdk=4
    
    # langversion refers to C# language features. see man mcs for details.
    langversion=${sdk}
    nuget_cmd=nuget
    
    # Match against our known SDK possibilities
    case "${sdk}" in
      4)
        langversion=4
        ;;
      4.5*)
        langversion=5
        ;;
      4.6*)
        langversion=6
        ;;
      4.7*)
        langversion=7 # ignoring 7.1 for now.
        ;;
      *)
        langversion=6
        ;;
    esac
    
    echo "[INFO] Target framework: ${frameworkVersion}"
    
    if ! type nuget &>/dev/null; then
        echo "[INFO] Download nuget and packages"
        wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe;
        nuget_cmd="mono nuget.exe"
    fi
    
    mozroots --import --sync
    ${nuget_cmd} install src/Swagger/packages.config -o packages;
    
    echo "[INFO] Copy DLLs to the 'bin' folder"
    mkdir -p bin;
    cp packages/Newtonsoft.Json.10.0.3/lib/net40/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll;
    cp packages/RestSharp.105.1.0/lib/net4/RestSharp.dll bin/RestSharp.dll;
    cp packages/JsonSubTypes.1.2.0/lib/net40/JsonSubTypes.dll bin/JsonSubTypes.dll
    
    echo "[INFO] Run 'mcs' to build bin/SwaggerTest.dll"
    mcs -langversion:${langversion} -sdk:${sdk} -r:bin/Newtonsoft.Json.dll,bin/JsonSubTypes.dll,
    bin/RestSharp.dll,
    System.ComponentModel.DataAnnotations.dll,
    System.Runtime.Serialization.dll 
    -target:library 
    -out:bin/SwaggerTest.dll 
    -recurse:'src/Swagger/*.cs' 
    -doc:bin/SwaggerTest.xml 
    -platform:anycpu
    
    if [ $? -ne 0 ]
    then
      echo "[ERROR] Compilation failed with exit code $?"
      exit 1
    else
      echo "[INFO] bin/SwaggerTest.dll was created successfully"
    fi

    在提供一个bat的脚本,

    创建编写 build.bat 脚本文件,内容如下:

    :: Generated by: https://github.com/swagger-api/swagger-codegen.git
    ::
    
    @echo off
    
    SET CSCPATH=%SYSTEMROOT%Microsoft.NETFrameworkv3.5
    
    if not exist ".
    uget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', '.
    uget.exe')"
    .
    uget.exe install srcSwaggerpackages.config -o packages
    
    if not exist ".in" mkdir bin
    
    copy packagesNewtonsoft.Json.10.0.3lib
    et40Newtonsoft.Json.dll binNewtonsoft.Json.dll
    copy packagesJsonSubTypes.1.2.0lib
    et40JsonSubTypes.dll binJsonSubTypes.dll
    copy packagesRestSharp.105.1.0lib
    et4RestSharp.dll binRestSharp.dll
    %CSCPATH%csc  /reference:binNewtonsoft.Json.dll;binJsonSubTypes.dll;binRestSharp.dll;System.ComponentModel.DataAnnotations.dll  /target:library /out:binSwaggerTest.dll /recurse:srcSwagger*.cs /doc:binSwaggerTest.xml    

    您的资助是我最大的动力!
    金额随意,欢迎来赏!
    款后有任何问题请给我留言。

    如果,您认为阅读这篇博客让您有些收获,不妨点击一下右下角的推荐按钮。
    如果,您希望更容易地发现我的新博客,不妨点击一下绿色通道的关注我。(●'◡'●)

    如果你觉得本篇文章对你有所帮助,请给予我更多的鼓励,求打             付款后有任何问题请给我留言!!!

    因为,我的写作热情也离不开您的肯定支持,感谢您的阅读,我是【Jack_孟】!

  • 相关阅读:
    (精华)将json数组和对象转换成List和Map(小龙哥和牛徳鹤的对话)
    优先队列底层实现是堆(heap)(操作系统进程调度)
    (透彻理解)最精锐代码::堆的三种基本操作新建-插入-删除
    (考研)读者写者问题(附代码)
    (考研)黑电吃苹果同步互斥问题(附代码)
    (考研)哲学家进餐问题(附代码)
    (考研)吸烟者问题(赋代码)
    (考研)PV操作和信号量
    01.第一章_C++ Primer学习笔记_开始
    C++学习笔记
  • 原文地址:https://www.cnblogs.com/mq0036/p/14918254.html
Copyright © 2020-2023  润新知