How to configure AWS CodeBuild to build ASP.NET 4 application

2.7k Views Asked by At

I have looked through AWS CodeBuild documentation and have googled this question in various forms, but haven't found anything relevant.

I have an ASP.NET 4 MVC application, that targets .NET Framework 4.5.2. And the big idea is to deploy this application automatically from git repository to several windows machines.

I have scripts that use AWS CLI and AWS CodeDeploy to build the application and deploy it from my dev-machine to our servers. These scripts work fine.

The next step, that I can't figure out how to do, is to use AWS CodeBuild (or maybe I should use some other AWS thing or not AWS thing) in order to pull code from git repository and run my build scripts (not on my dev-machine). But it seems like CodeBuild is able to work only with Unix/Linux environments and not with Windows + .NET Framework.

The question is: Is there a way to use CodeBuild or some other AWS service in order to pull code from git repository and build ASP.NET 4 application that targets .NET Framework and how to do this?

2

There are 2 best solutions below

0
On BEST ANSWER

Unless something has changed very recently, AWS CodeBuild only supports .net Core applications, not the traditional .net framework.

You could install Jenkins (or other similar tool) on an EC2 instance and integrate it into your process, but that will require you to do most of the work yourself in terms of getting it working.

2
On

Amazon, as of May-2018, supports Windows hosts. Combine that with the Microsoft .NET Framework Build Image, I have been able to get it working. Here is a preliminary buildspec.yml to get started with:

version: 0.2

# Assumes the image is microsoft/dotnet-framework:4.7.2-sdk or similar
phases:
  install:
    commands:
      # Below is the URL for the MSI linked from https://www.iis.net/downloads/microsoft/web-deploy
      - Invoke-WebRequest -OutFile WebDeploy_amd64_en-US.msi https://download.microsoft.com/download/0/1/D/01DC28EA-638C-4A22-A57B-4CEF97755C6C/WebDeploy_amd64_en-US.msi
      - msiexec /i WebDeploy_amd64_en-US.msi /quiet
      # MSIExec will return before it is actually done - 30s seems to work...
      - Start-Sleep 30
  pre_build:
    commands:
      - nuget restore
  build:
    commands:
      - msbuild /P:Configuration=Release /T:Build,Package