简体   繁体   English

依赖项被复制到 Azure DevOps 中的私有源

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

I have set up a build pipeline for a model library that's shared between several of my projects.我已经为我的几个项目之间共享的模型库设置了构建管道。 I'm accessing it through a private feed in Azure DevOps, and it works just fine.我正在通过 Azure DevOps 中的私有源访问它,它运行良好。 I can retrieve the library in Visual Studio and my projects all get the most up-to-date version.我可以在 Visual Studio 中检索库,我的项目都获得最新版本。 However, in the feed are all the dependency libraries used within the model library (eg Microsoft.Azure.Storage.Blob, System.Threading, Microsoft.AspNetCore, etc.).但是,提要中包含模型库中使用的所有依赖项库(例如 Microsoft.Azure.Storage.Blob、System.Threading、Microsoft.AspNetCore 等)。 I haven't been able to find any guidance on why this is happening, if it's the expected behavior, or if I'm screwing something up.我无法找到任何关于为什么会发生这种情况的指导,如果这是预期的行为,或者我是否搞砸了某些事情。 My YAML file for the build pipeline is below:我的构建管道 YAML 文件如下:

Also, does anyone know a better to handle package versioning?另外,有没有人知道更好地处理包版本控制? This seems really hacky, but it was the only way I could get auto-incrementing versions to work.这看起来真的很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>'

Dependencies getting copied to private feed in Azure DevOps依赖项被复制到 Azure DevOps 中的私有源

That because your private Nuget Feed set nuget.org as an Upstream source by default if you set Package from public sources enable when you create the this feed:那是因为如果您在创建此提要时将来自公共源的包设置为启用,则默认情况下您的私有 Nuget 提要将 nuget.org 设置为上游源:

在此处输入图片说明

Then go to Setting->Upstream source, you will find there are three public sources listed:然后去设置->上游源,你会发现列出了三个公共源:

在此处输入图片说明

When we download any packages from the Upstream sources, it will been cached in the Artifacts, you will see it next time.当我们从 Upstream 源下载任何包时,它会缓存在 Artifacts 中,您下次会看到它。 They are cached packages from upstream sources, so we do not need to download them again from upstream sources next time we use them, and the included upstream sources are all approved by MS , so you do not need to worry about them.它们是上游源的缓存包,所以下次使用时我们不需要再次从上游源下载它们,并且包含的​​上游源都是MS认可的,因此您无需担心它们。

Besides, if you still worry about them, you can disable the Upstream sources, but in this case, you need publish all the dependencies to your private feed, otherwise, your model library package will throw the error could not found the dependencies .此外,如果您仍然担心它们,您可以禁用上游源,但在这种情况下,您需要将所有依赖项发布到您的私有源,否则,您的模型库包将抛出错误could not found the dependencies

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM