繁体   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