簡體   English   中英

依賴項被復制到 Azure DevOps 中的私有源

[英]Dependencies getting copied to private feed in Azure DevOps

我已經為我的幾個項目之間共享的模型庫設置了構建管道。 我正在通過 Azure DevOps 中的私有源訪問它,它運行良好。 我可以在 Visual Studio 中檢索庫,我的項目都獲得最新版本。 但是,提要中包含模型庫中使用的所有依賴項庫(例如 Microsoft.Azure.Storage.Blob、System.Threading、Microsoft.AspNetCore 等)。 我無法找到任何關於為什么會發生這種情況的指導,如果這是預期的行為,或者我是否搞砸了某些事情。 我的構建管道 YAML 文件如下:

另外,有沒有人知道更好地處理包版本控制? 這看起來真的很hacky,但這是我可以讓自動遞增版本工作的唯一方法。

# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

name: $(projectName)-$(majorMinorVersion).$(semanticVersion)

pool:
  vmImage: 'windows-latest'

# pipeline variables
variables:
  majorMinorVersion: 1.1
  # semanticVersion counter is automatically incremented by one in each execution of pipeline
  # second parameter is seed value to reset to every time the referenced majorMinorVersion is changed
  semanticVersion: $[counter(variables['majorMinorVersion'], 0)]
  projectName: 'MyProject.Models'
  buildConfiguration: 'Release'
  projectPath: 'Shared/MyProject.Models.csproj'
  fullVersion: '$(majorMinorVersion).$(semanticVersion)'

steps:
# show version number on start
- task: Bash@3
  inputs:
    targetType: 'inline'
    script: |
      echo Building $(projectName)-$(fullVersion)

- task: DotNetCoreCLI@2
  inputs:
    command: 'pack'
    packagesToPack: $(projectPath)
    versioningScheme: 'byEnvVar'
    versionEnvVar: 'fullVersion'

- task: DotNetCoreCLI@2
  inputs:
    command: 'push'
    packagesToPush: '$(Build.ArtifactStagingDirectory)/MyProject.Models*.nupkg'
    nuGetFeedType: 'internal'
    publishVstsFeed: '<feed GUID>'

依賴項被復制到 Azure DevOps 中的私有源

那是因為如果您在創建此提要時將來自公共源的包設置為啟用,則默認情況下您的私有 Nuget 提要將 nuget.org 設置為上游源:

在此處輸入圖片說明

然后去設置->上游源,你會發現列出了三個公共源:

在此處輸入圖片說明

當我們從 Upstream 源下載任何包時,它會緩存在 Artifacts 中,您下次會看到它。 它們是上游源的緩存包,所以下次使用時我們不需要再次從上游源下載它們,並且包含的​​上游源都是MS認可的,因此您無需擔心它們。

此外,如果您仍然擔心它們,您可以禁用上游源,但在這種情況下,您需要將所有依賴項發布到您的私有源,否則,您的模型庫包將拋出錯誤could not found the dependencies

希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM