环境部署
Linux系统:Debian10
包管理服务器:ProGet
首先,在Debian10上安装mono,安装步骤:https://www.mono-project.com/download/stable/#download-lin-debian
其次,下载Paket发布版本,地址为:https://github.com/fsprojects/Paket/releases
然后,将paket.exe拷贝到/usr/local/bin
目录下,然后就可以使用paket.exe进行拉包、打包。
Paket使用
下面讲述一种简单的使用示例,详细介绍参加:https://fsprojects.github.io/Paket/learn-how-to-use-paket.html
通常情况下,在一个工程的根目录需要五个Paket相关的文件:
- paket.dependencies
- paket.lock
- paket.template
- paketpull.sh
- paketpush.sh
paket.dependencies
该文件记录当前工程依赖的库文件,如下示例
source http://127.0.0.1:8624/nuget/test/
nuget libbase00 = 1.0.0
paket.lock
当拉取依赖库后,当前工程的依赖库及版本都会记录到该文件中;当依赖库版本有变更时,下次拉取依赖库,会更新该文件中的记录。
该文件可以一直为空,也可以保留自动记录的依赖库及版本。
paket.template
该文件记录打包的模板,如下示例
type file
id libbase10
version 1.0.0
authors xxxx
description
base library
files
*.h ==> include
*.h ==> src
*.cpp ==> src
libbase10.a ==> lib
dependencies
libbase00 = LOCKEDVERSION
其中,files
表示要打包的文件,左边为本地文件路径,右边为打包文件的相对路径,如果放在打包文件的根目录,可以写为空或“.”。
dependencies
表示当前工程的依赖库及其版本,如果其它库和当前工程有相同的依赖库,该项可以避免依赖库不一致的问题。
paketpull.sh
该脚本的名称可自定义,作用是根据paket.dependencies
中的记录拉取当前工程的依赖库,并将其记录到paket.lock
中。使用示例如下
#!/bin/bash
paket.exe clear-cache --clear-local
paket.exe install
paketpush.sh
该脚本的名称可自定义,作用是根据paket.template
中的记录生成打包文件,并上传到包管理服务器上。使用示例如下
#!/bin/bash
packout=pack.out
project=libbase10
packversion=1.0.0
paket.exe pack --template paket.template --version $packversion $packout >> pack.log
if [ $? -ne 0 ]; then
echo "pack error"
exit 1
fi
paket.exe push --url http://127.0.0.1:8624/nuget/test/ --api-key test.com ./$packout/$project.$packversion.nupkg >> push.log
if [ $? -ne 0 ]; then
echo "upload error"
exit 1
fi