引用feed到项目和pipeline中

 

Reference the Models package

  1. Open the Tailspin.SpaceGame.Web.csproj file, add the following PackageReference, and save the file.

    <ItemGroup>
      <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
      <PackageReference Include="Tailspin.SpaceGame.Web.Models" Version="1.0.0" />
    </ItemGroup>
    
  2. Modify the version number to include the pre-release prefix that was generated during the build process. Here's an example.

    <PackageReference Include="Tailspin.SpaceGame.Web.Models" Version="1.0.0-CI-20200610-165738" />
    

    This references the Tailspin.SpaceGame.Web.Models package that you created in Azure Artifacts. Notice the version number, 1.0.0, plus the pre-release suffix. This matches the initial version that you published to Azure Artifacts in the previous part.

When you save the file, Visual Studio Code might ask you to restore dependencies. We're not going to run this locally, so there is no need to restore the dependencies.

Add the pipeline configuration

The models-package branch doesn't contain an initial azure-pipelines.yml file. Here's your chance to create it.

  1. From Visual Studio Code, select File > New File. Then select File > Save to save the blank file as azure-pipelines.yml in your project's root directory, such as ~/mslearn-tailspin-spacegame-web.

    On Windows, ensure that you select YAML from the Save as type field.

  2. Copy the following YAML code into azure-pipelines.yml:

    trigger:
    - '*'
    
    pool:
      vmImage: 'ubuntu-18.04'
      demands:
      - npm
    
    variables:
      buildConfiguration: 'Release'
      wwwrootDir: 'Tailspin.SpaceGame.Web/wwwroot'
      dotnetSdkVersion: '3.1.300'
    
    steps:
    - task: UseDotNet@2
      displayName: 'Use .NET Core SDK $(dotnetSdkVersion)'
      inputs:
        version: '$(dotnetSdkVersion)'
    
    - task: NuGetToolInstaller@0
      inputs:
        versionSpec: '5.6.0' 
    
    - task: Npm@1
      displayName: 'Run npm install'
      inputs:
        verbose: false
    
    - script: './node_modules/.bin/node-sass $(wwwrootDir) --output $(wwwrootDir)'
      displayName: 'Compile Sass assets'
    
    - task: gulp@1
      displayName: 'Run gulp tasks'
    
    - script: 'echo "$(Build.DefinitionName), $(Build.BuildId), $(Build.BuildNumber)" > buildinfo.txt'
      displayName: 'Write build info'
      workingDirectory: $(wwwrootDir)
    
    - task: NuGetCommand@2
      displayName: 'Restore project dependencies'
      inputs:
        command: 'restore'
        restoreSolution: '**/*.sln'
        feedsToUse: 'select'
        vstsFeed: 'Space Game - web - Dependencies/Tailspin.SpaceGame.Web.Models'
    
    - task: DotNetCoreCLI@2
      displayName: 'Build the project - $(buildConfiguration)'
      inputs:
        command: 'build'
        arguments: '--no-restore --configuration $(buildConfiguration)'
        projects: '**/*.csproj'
    
    - task: DotNetCoreCLI@2
      displayName: 'Publish the project - $(buildConfiguration)'
      inputs:
        command: 'publish'
        projects: '**/*.csproj'
        publishWebProjects: false
        arguments: '--no-build --configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)/$(buildConfiguration)'
        zipAfterPublish: true
    
    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact: drop'
      condition: succeeded()
    

    The highlighted code shows where the pipeline restores dependencies, and looks in your Azure Artifacts feed for the dependencies that might be there.

  3. Stage, commit, and push your changes to GitHub.

    git add .
    git commit -m "Add reference to Models package"
    git push origin models-package
    
  4. Go to Microsoft Azure Pipelines and watch the build run. The build picks up your Models package from Azure Artifacts, and builds the project successfully.

 

 

原文:Reference the package from the application

https://docs.microsoft.com/zh-cn/learn/modules/manage-build-dependencies/6-consume-package

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值