3

I'm trying to setup up a proof of concept CI/CD in AWS. I need to build a .net mvc project (not core but standard).

So what I've figured so far is that we need to define a pipeline, getting code trough a source (in my case github) and putting it in S3, then CodeBuild builds it, then CodeDeploy deploys it.

I've found posts saying building standard .net is not yet supported by the CodeBuild as it does not have the windows server option. But the post is dated and it actually has windows option right now - See picture below.

shows windows server is available

So I thought it now can support standard .net builds, but I'm having trouble to find any documentation around it. Where I stuck is actually setting up the buildspec.yml file. I have no idea how to set it up for a standard .net mvc application. The aforementioned post tells how to create the buildspec.yml but for .net core, hence not working for me.

Can anyone help me to get around this?

Or should I really go ahead and setup a jenkins server and walk from there?

Tolga Evcimen
  • 7,112
  • 11
  • 58
  • 91

3 Answers3

3

https://aws.amazon.com/blogs/devops/extending-aws-codebuild-with-custom-build-environments-for-the-net-framework/ describes how to use custom Docker images for your Windows builds.

Some samples are available in CodeBuild documentation: https://docs.aws.amazon.com/codebuild/latest/userguide/sample-windows.html

Subin Mathew
  • 2,335
  • 1
  • 16
  • 24
2

Amazon, as of May-2018, supports Windows hosts so yes, it is possible. 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
David Beckman
  • 605
  • 8
  • 17
  • using the build image provided and buildspec.yml you provided. Getting nuget restore. Reason: exit status 1 also tried changed the pre_build command to "cd Project.Web && nuger restore" – jmogera Feb 06 '19 at 01:33
  • the *.sln file is in the root of my source directory and the *.csproj file is ./{ProjectName}/{ProjectName}.csproj - i have had no troubles there. the first line I see is: MSBuild auto-detection: using msbuild version '15.9.21.664' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin'. – David Beckman Feb 13 '19 at 16:47
  • @DavidBeckman how did you figure out "# Assumes the image is microsoft/dotnet-framework:4.7.2-sdk or similar"? I can't find any information on how the "aws/codebuild/windows-base/*" images are built. – Sam Sippe Mar 23 '20 at 21:27
  • @SamSippe When working with code build, you can specify what image your build container comes from. This script, specifically the install commands, assume that image is from Microsoft. If you are using a different container image, there will be a different set of prerequisites to setup the image (possibly none). – David Beckman Apr 21 '20 at 00:01
1

Been around a few loopholes in an attempt to achieve this myself now, the answer is not black or white I'm afraid.

AWS CodeBuild do support .net build, but I strongly advise against it because of the time cost (and pain) of a few issues.

  1. Finding and understanding the buildspec configuration is cumbersome here
  2. Fixing the missing references, (such as missing Microsoft.WebApplication.targets).

I myself ran into another bug with long filenames not being supported, who knows what comes next.

Even the workarounds have workarounds, so lets face it. Its not very good for the specific purpose of building via msbuild, whom comes to me as a big dissatisfaction.

My next attempt will be to automate direct upload of build to S3, so a localhost build and server side deploy procedure. Not what I initially had intended.

Christopher Bonitz
  • 828
  • 1
  • 10
  • 22