欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

引用feed到项目和pipeline中

程序员文章站 2022-03-09 12:14:49
...

 

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: [email protected]
      displayName: 'Use .NET Core SDK $(dotnetSdkVersion)'
      inputs:
        version: '$(dotnetSdkVersion)'
    
    - task: [email protected]
      inputs:
        versionSpec: '5.6.0' 
    
    - task: [email protected]
      displayName: 'Run npm install'
      inputs:
        verbose: false
    
    - script: './node_modules/.bin/node-sass $(wwwrootDir) --output $(wwwrootDir)'
      displayName: 'Compile Sass assets'
    
    - task: [email protected]
      displayName: 'Run gulp tasks'
    
    - script: 'echo "$(Build.DefinitionName), $(Build.BuildId), $(Build.BuildNumber)" > buildinfo.txt'
      displayName: 'Write build info'
      workingDirectory: $(wwwrootDir)
    
    - task: [email protected]
      displayName: 'Restore project dependencies'
      inputs:
        command: 'restore'
        restoreSolution: '**/*.sln'
        feedsToUse: 'select'
        vstsFeed: 'Space Game - web - Dependencies/Tailspin.SpaceGame.Web.Models'
    
    - task: [email protected]
      displayName: 'Build the project - $(buildConfiguration)'
      inputs:
        command: 'build'
        arguments: '--no-restore --configuration $(buildConfiguration)'
        projects: '**/*.csproj'
    
    - task: [email protected]
      displayName: 'Publish the project - $(buildConfiguration)'
      inputs:
        command: 'publish'
        projects: '**/*.csproj'
        publishWebProjects: false
        arguments: '--no-build --configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)/$(buildConfiguration)'
        zipAfterPublish: true
    
    - task: [email protected]
      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