博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Visual Studio下运行PowerShell脚本自增小版本号并发布到Nuget服务器上
阅读量:6971 次
发布时间:2019-06-27

本文共 1198 字,大约阅读时间需要 3 分钟。

Visual Studio下运行PowerShell脚本自动更新项目里AssemblyInfo.cs文件的版本(
自增小版本号)并发布到Nuget服务器上

 

附脚本【 update.ps1文件内容】:

 

$path="Properties\AssemblyInfo.cs"
$pattern = '\[assembly: AssemblyVersion\("(.*)"\)\]'
(Get-Content $path) | ForEach-Object{
if($_ -match $pattern){
# We have found the matching line
# Edit the version number and put back.
$fileVersion = [version]$matches[1]
$newVersion = "{0}.{1}.{2}.{3}" -f $fileVersion.Major, $fileVersion.Minor, $fileVersion.Build, ($fileVersion.Revision + 1)
'[assembly: AssemblyVersion("{0}")]' -f $newVersion
} else {
# Output line as is
$_
}
} | Set-Content $path  -Encoding utf8
$pattern = '\[assembly: AssemblyFileVersion\("(.*)"\)\]'
(Get-Content $path) | ForEach-Object{
if($_ -match $pattern){
# We have found the matching line
# Edit the version number and put back.
$fileVersion = [version]$matches[1]
$newVersion = "{0}.{1}.{2}.{3}" -f $fileVersion.Major, $fileVersion.Minor, $fileVersion.Build, ($fileVersion.Revision + 1)
'[assembly: AssemblyFileVersion("{0}")]' -f $newVersion
} else {
# Output line as is
$_
}
} | Set-Content $path  -Encoding utf8
nuget pack  -Build -OutputFileNamesWithoutVersion
nuget push -Source "
http://****" -ApiKey {
password} Demo.nupkg

转载地址:http://cxasl.baihongyu.com/

你可能感兴趣的文章
CSS和JS实现单行、多行文本溢出显示省略号(该js方法有问题不对)
查看>>
小细节大改变:用户信息缓存以及其他几点ajax请求的优化
查看>>
新浪微博URL中的MID和微博id互转
查看>>
第六章学习小结
查看>>
py 的 第28 天
查看>>
BZOJ 2627 JZPKIL
查看>>
XE8_TPaintBox画
查看>>
你真的会玩SQL吗?冷落的Top和Apply
查看>>
文件中数组的最大值及其对应的最小下标
查看>>
简单的分页存储过程,Json格式日期转换为一般日期
查看>>
算24 (递归)
查看>>
python之dict
查看>>
Lua中的元表与元方法
查看>>
将银行读卡设备读取到的身份证头像Bitmap属性转换成路径
查看>>
iPhone5,发布的不仅仅是一部手机
查看>>
Vue路由参数设置可有可无
查看>>
codevs 3115 高精度练习--减法
查看>>
使用 Swoole 来加速你的 Laravel 应用
查看>>
9月15日学习内容整理:类的命名空间和组合
查看>>
SSD详解
查看>>