1
votes

I have an AWS CodeBuild process kicking off whenever I check code into master branch of my GitHub repo. My codebase is a dotnet core serverless application. I have a dependency on a private nuget package residing in GitHub Package Repository. My CodeBuild process is failing when trying to find the package:

error NU1101: Unable to find package datastop.io.data-dictionary. 
No packages exist with this id in source(s): nuget.org 

datastop.io.data-dictionary is a private nuget package residing in GitHub Package Repository, not in nuget.org. It appears from the error message the CodeBuild process is attempting to find 'datastop.io.data-dictionary' in nuget.

Here's my current buildspec.yml file:

version: 0.2
phases:
    install:
        runtime-versions:
            dotnet: 2.1
        commands:
            - echo Entered the install phase...
            - export PATH="$PATH:/root/.dotnet/tools"
            - dotnet tool install -g Amazon.Lambda.Tools
    pre_build:
        commands:
            - echo Entered the pre_build phase...
            - dotnet restore
    build:
        commands:
            - echo Entered the build phase...
            - echo Build started on `date`
            - cd $FOLDER
            - dotnet lambda package --configuration release --framework netcoreapp2.1 -o ./$ZIPPED_APPLICATION
            - aws cloudformation package --template-file infrastructure.yml --s3-bucket $S3_DEPLOYMENT_BUCKET --output-template-file packaged-infrastructure.yml --region us-east-2
            - aws cloudformation deploy --template-file packaged-infrastructure.yml --stack-name $CLOUDFORMATION_STACK_NAME --capabilities CAPABILITY_IAM --region us-east-2

The build process is failing while running dotnet restore.

I'm assuming I need to modify my buildspec.yml file somehow to let the build process know to look at the correct package repository (our private GitHub Package Repository). How do I modify my buildspec.yml file to point to the appropriate GitHub Package Repository when trying to find datastop.io.data-dictionary package?

1

1 Answers

1
votes

If you add a nuget.config file to your project, and add your GitHub repo to that config it will know where to look. From there it's a question of permissions, which is what I'm struggling with.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <clear />
        <add key="github" value="https://nuget.pkg.github.com/YOUR_ACCOUNT_NAME/index.json" />
    </packageSources>
</configuration>