With the recent announcements from AWS, AWS CodeBuild is now capable of building and deploying .NET Core applications. In this short column, I will demonstrate how I was able to build a sample ASP.NET Core application.
In this example I used CodeCommit to host my repo. I also tried it with Github and it worked exactly the same way.
Let’s start by creating a new .NET Core application
dotnet new mvc --name SampleCore
After initialising git on the repo, let’s go ahead and create the repository in CodeCommit
The next thing we want to do is configure CodeBuild with our repository
And then we connect to our repository in CodeCommit. This is where you can select Github and login with your Github account
Once that is completed, then we can start the build
Our build was not successful but CodeBuild is complaining about the missing build config
We need to add our `buildspec.yml` so that CodeBuild knows how to interact with the .NET Core CLI and build our project. Our build specification looks like the following:
version: 0.2 phases: pre_build: commands: - echo Restore started on `date` - dotnet restore SampleCore.csproj build: commands: - echo Build started on `date` - dotnet publish -c release -o ./build_output SampleCore.csproj artifacts: files: - CodeBuild-SampleCore/build_output/**/* - scripts/**/*
Once we add the file, then we can start a new build, and this time it’s successful.
You can review the complete code on github and try it out yourself. If you are interesting in building the complete workflow and you are looking with a solution to automatically provision resources to release the software, then you should check out CodeStar. CodeStar has templates for .NET Core projects as well.