DEV Community

Mohsen Kokabi
Mohsen Kokabi

Posted on • Updated on

AWS CodeBuild DotNet Core

Goto CodeBuild services tab.
Image01

Start with creating a build project:
Image02

Chose your source control management. Here we are selecting the one we created on another post on AWS CodeCommit
Image03

Select the Environment as Managed Image and Operating as Ubuntu and Runtime as Standard and the latest image version.
After selecting the image the Role name would be generated like:
codebuild-{The build project name}-service-role

For instance in our sample:
codebuild-MohsenTestBuild-service-role

Image04

Select Insert build commands and the click on Switch to editor.
Image05

Edit Buildspec the pre_build and build sections as:

  pre_build:
    commands:
      dotnet restore WebAppTest.csproj
  build:
    commands:
      dotnet build WebAppTest.csproj

Now start the build
Image07

Hit the Start build
Image08

The build should get successfully completed.
Image09

Note: Currently the AWS Code build doesn't support .Net Core 3.1.

Phase 2:

Now that the build is successful we can edit the build artifact settings:
Image12

And add a S3 bucket to the artifact.

Image10

And also modify the build spec and add the artifact.

  pre_build:
    commands:
      dotnet restore WebAppTest.csproj
  build:
    commands:
      dotnet publish -c release WebAppTest.csproj -o ./publish_output

artifacts:
  files:
    - ./publish_output/**/*

Now the build should ends with steps of copying the artifacts to S3.
Image11

Top comments (0)