• Nuget私有库搭建 打包依赖问题


    之前就有在公司做私有库的搭建:

    1、直接写个bat 命令,在VS中配制菜单,可在项目上右键发布。(网上很多这种教程)

      1.1 版本号问题无语

      1.2 项目多了也是无语

    2、之前的技术群友推荐用了一个工具NuPack的VS插件

      可能是我太菜,不太会用,还是觉得麻烦,项目多了,一起打包累

    3、就是脚本了,这个方便,快,还打包的全

    看了很多网上的资料,就第三种最好用,小改一下就能通吃

    网上遇到最多的问题就是 打包后 没有把依赖也一起打包,这就是个坑 我找了很久,被自己蠢屎,还是要多看官网文档。

    就是看了这篇文档,什么事都解决了:https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-pack

    我的思路是这样的:

    A、先把所有项目release编译 来一波 脚本 build-all.ps1

    # COMMON PATHS
    $rootFolder = (Get-Item -Path "./" -Verbose).FullName
    
    # List of solutions
    #要编译的文件目录列表,也可以是根目录
    $solutionPaths = (
        "framework",
        "modules/users",
        "modules/permission-management"
    )
    
    # Build all solutions
    foreach ($solutionPath in $solutionPaths) {    
        $solutionAbsPath = (Join-Path $rootFolder $solutionPath)
        Set-Location $solutionAbsPath
        #release 
        dotnet build -c release
        if (-Not $?) {
            Write-Host ("Build failed for the solution: " + $solutionPath)
        }
    }
    
    Set-Location $rootFolder
    pause

    B、再生成Nuget包 并推送

    # COMMON PATHS
    $rootFolder = (Get-Item -Path "./" -Verbose).FullName
    #定义当前发布包版本号
    $version = "1.0.0.1"
    
    # List of solutions
    $solutionPaths = (
        "framework",
        "modules/users", 
       "modules/permission-management"
    ) # Build all solutions foreach ($solutionPath in $solutionPaths) { $solutionAbsPath = (Join-Path $rootFolder $solutionPath) Set-Location $solutionAbsPath #查找所有*.csproj文件 并遍历 Get-ChildItem -Path $solutionAbsPath -Include *.csproj -Recurse |` foreach{ $Item = $_ $Path = $_.FullName $ParentS = ($_.Fullname).split("") $Parent = $ParentS[@($ParentS.Length - 2)] $BasePath="E:LocalNuGetNugetConfigPacker" #组合发布名文件名 $FileName = "$BasePathTemp$Parent.$version.nupkg" #这里的好戏来了,是 donet pack 不是 nuget pack ,以及后面的命令也不同,参考上面的文档,用这个命令 dotnet pack 就能根据csproj里面拿到包的依赖
         #因为上面已经release了,所以这里不用重复编译
    dotnet pack --no-build --no-restore -c release -p:PackageVersion=$version --output "$BasePathTemp" #下面这个也能打包,但是,不能把包依赖打包,也是服,不要用不要用 ##nuget pack $Path -c release -Version $version -OutputDirectory "$BasePathTemp" #下面这里就推送到 私有库 nuget push $FileName "10086" -Source "http://192.168.18.122:10086/nuget" #干完上面的事,就从临时文件夹移出来 move $FileName $BasePath if (-Not $?) { Write-Host ("Build failed for the solution: " + $solutionPath) Set-Location $rootFolder exit $LASTEXITCODE } } } Set-Location $rootFolder pause

    以上两步为什么不放在一起,而要分开两步呢?

    嗨,大家试下就知道,两步放一起项目多的话 要多久了,反正我一百多个项目打包放一起一个下午没了 才跑完,分开跑快的不是一点半点

    先留记录在这里 备忘!

    记录自己能看懂的笔记,利人利己
  • 相关阅读:
    mysql之 共享表空间与独立表空间、frm,MYD,MYI.idb,par文件说明
    利用PS脚本自动删除7天之前建立的目录-方法1!
    走进C++程序世界-----继承和派生(2)
    Thinkpad SL400安装黑苹果10.8.4全纪录
    ASM集群文件系统ACFS(ASM Cluster File System)
    上传GIF图片方法!
    .NET通用基本权限系统
    Android项目实战--手机卫士24--程序锁的实现以及逻辑
    大数记录之,大数乘整型数nyoj832
    与IO相关的等待事件troubleshooting-系列9
  • 原文地址:https://www.cnblogs.com/JalanWang/p/12055746.html
Copyright © 2020-2023  润新知