zoukankan      html  css  js  c++  java
  • windows右键菜单自动打包发布nuget,没有CI/CD一样方便!

    构建现代的 .Net 应用离不开 Nuget 的支持,而快速打包 Nuget 成了提高生产率的有效方法。没有CI/CD?来试试使用windows右键菜单吧

    先看右键效果图

    有时候我们可能没有CI/CD的条件来自动发布nuget包,这个时候文件夹右键菜单就显得十分高效了
    如图所示,直接在文件夹右键可以看到又nuget publish的菜单按钮

    如何实现

    具体的操作是修改 windows 的注册表,具体可以参考 windows 下如何修改右键菜单 一文

    这里我写了2个注册表脚本分享一下

    bata版发布:

    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINESOFTWAREClassesDirectoryshellNuget]
    @="Nuget Publish-beta"
    
    [HKEY_LOCAL_MACHINESOFTWAREClassesDirectoryshellNugetcommand]
    @="powershell.exe -noexit -command Set-Location -literalPath '%V' ;powershell.exe  -c "echo $pwd;del *.nupkg ;$ver = -join ((Get-Date -format 'yyyy.MMdd.HH.mm'),'-beta');$outputpwd=$pwd;foreach($item in (ls $pwd -R | ?{$_.psiscontainer -eq $true} | Where-Object {Test-Path (join-path $_.fullname *)  -include '*.csproj'})){dotnet pack $item.fullname --configuration Release --output  $outputpwd /p:Version=$ver;}$nupkg= dir *.nupkg; dotnet nuget push $nupkg -k chx666 -s http://192.168.1.24:8080;del $nupkg""
    
    

    正式版发布:

    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINESOFTWAREClassesDirectoryshellNuget]
    @="Nuget Publish-beta"
    
    [HKEY_LOCAL_MACHINESOFTWAREClassesDirectoryshellNugetcommand]
    @="powershell.exe -noexit -command Set-Location -literalPath '%V' ;powershell.exe  -c "echo $pwd;del *.nupkg ;$ver = (Get-Date -format 'yyyy.MMdd.HH.mm');$outputpwd=$pwd;foreach($item in (ls $pwd -R | ?{$_.psiscontainer -eq $true} | Where-Object {Test-Path (join-path $_.fullname *)  -include '*.csproj'})){dotnet pack $item.fullname --configuration Release --output  $outputpwd /p:Version=$ver;}$nupkg= dir *.nupkg; dotnet nuget push $nupkg -k chx666 -s http://192.168.1.24:8080;del $nupkg""
    
    

    搞定

    将文本另存为 xxx.reg(注意,文件编码需要UTF-16 LE, 不然右键菜单点击会报错),双击即可导入到系统,然后重启 windows 资源管理器的进程(就是我的电脑的进程)。
    然后右键就可以体验啦,搞定收工。

    最后

    欢迎大家体验评论,使用后欢迎各位给出更好的脚本方案评论

  • 相关阅读:
    poj-2478 Farey Sequence(dp,欧拉函数)
    codeforces 515C C. Drazil and Factorial(水题,贪心)
    hdu-5643 King's Game(打表)
    可以在命令行直接使用密码来进行远程连接和远程拉取文件的命令:sshpass
    查看SQL运行时间
    管理kafka
    No module named _sqlite3
    ps
    Redis之RDB与AOF
    Redis 4 参数解释
  • 原文地址:https://www.cnblogs.com/fanshaoO/p/15432690.html
Copyright © 2011-2022 走看看