【问题标题】:Automatically pick the latest version of private assembly packagereference Nuget自动挑选最新版本的私有程序集包参考 Nuget
【发布时间】:2019-07-24 05:38:55
【问题描述】:

我知道以前有人问过这个问题,但没有任何答案,或者 nuget 没有很好地听取我的包参考。

我有一个私人 nuget 仓库,有 2 个程序集:

<PackageReference Include="ProjectX.Core" Version="1.0.0.20" />
<PackageReference Include="ProjectX.Domain" Version="1.0.0.20" />

我想要的是 nuget 在恢复时自动获取最新版本(通过 azure devops),根据official docs 我应该这样做:

<PackageReference Include="ProjectX.Core" Version="1.*" />
<PackageReference Include="ProjectX.Domain" Version="1.*" />

但是当我查看它时,它会尝试恢复到版本 1.0.0(甚至不可用)。

如何让nuget自动获取最新版本?

【问题讨论】:

    标签: .net-core nuget packagereference


    【解决方案1】:

    “为我工作”。如果它不适合您,如果您可以提供Minimal, Complete, and Verifiable example,我们也许可以调试并查看问题所在。

    复制步骤:

    # setup isolated nuget environment
    dotnet new nugetconfig
    # you need to download nuget.exe for these commands, otherwise you have to hand edit nuget.config
    nuget config -configfile .\nuget.config -set globalPackagesFolder=gpf
    nuget sources -configfile .\nuget.config remove -name nuget
    nuget sources -configfile .\nuget.config add -name local -source source
    
    # create nupkgs
    dotnet new classlib -n MyLib
    cd MyLib
    dotnet msbuild -t:pack -p:packageoutputpath=..\source -p:version=1.0.0.1
    dotnet msbuild -t:pack -p:packageoutputpath=..\source -p:version=1.0.0.2
    dotnet msbuild -t:pack -p:packageoutputpath=..\source -p:version=1.0.0.10
    cd ..
    
    # use latest version
    dotnet new console -n MyApp
    cd MyApp
    dotnet add package MyLib --version "1.*"
    
    # check version used. I'm using Powershell
    Select-String -Path .\obj\project.assets.json -Pattern MyLib/
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-15
      • 1970-01-01
      相关资源
      最近更新 更多