码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2021-06-22 18:25:47      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:else   pos   lang   set   match   fail   ESS   reference   one   

创建编写 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.NET\Framework\v3.5

if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile(‘https://dist.nuget.org/win-x86-commandline/latest/nuget.exe‘, ‘.\nuget.exe‘)"
.\nuget.exe install src\Swagger\packages.config -o packages

if not exist ".\bin" mkdir bin

copy packages\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll bin\Newtonsoft.Json.dll
copy packages\JsonSubTypes.1.2.0\lib\net40\JsonSubTypes.dll bin\JsonSubTypes.dll
copy packages\RestSharp.105.1.0\lib\net4\RestSharp.dll bin\RestSharp.dll
%CSCPATH%\csc  /reference:bin\Newtonsoft.Json.dll;bin\JsonSubTypes.dll;bin\RestSharp.dll;System.ComponentModel.DataAnnotations.dll  /target:library /out:bin\SwaggerTest.dll /recurse:src\Swagger\*.cs /doc:bin\SwaggerTest.xml    

 

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

标签:else   pos   lang   set   match   fail   ESS   reference   one   

原文地址:https://www.cnblogs.com/mq0036/p/14918254.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!