Break New Ground

Build and Deploy .Net Code using Oracle Developer Cloud

Abhinav Shroff
Principal Product Manager

The much awaited support for building and deploying .Net code on Oracle Cloud using Developer Cloud Service is here.

This blog post will show how you can use Oracle Developer Cloud Service to build .Net code and deploy it on Oracle Application Container Cloud. It will show how the newly released Docker build support in Developer Cloud can be leveraged to perform the build.

Technology Stack Used:

Application Stack: .Net for developing ASPX pages

Build: Docker for compiling the .Net code

Packaging Tool: Grunt to package the compiled code

DevOps Cloud Service: Oracle Developer Cloud

Deployment Cloud Service: Oracle Application Container Cloud

OS for Development: Windows 7


.Net application code source:

 The ASP.Net application that we would be building and deploying on Oracle Cloud using Docker can be downloaded from the Git repository on GitHub. Below is the link for the same.


If you want to clone the GitHub repository then use the below git command after installing the git cli on your machine.

git clone https://github.com/dotnet/dotnet-docker-samples/

After cloning the above mentioned repository you can pick to use the aspnetapp. Below is the folder structure of the cloned aspnetapp.


Apart from the four highlighted files in the screen shot below, which are essential for the deployment, rest all the other files and folder are part of the .Net application.

Note: You may not be able to see the .get folder as you have not initialized the Git repository.

Now we need to initialize the Git repository for the aspnetappl as we will be pushing this code to the Git repo hosted on Oracle Developer Cloud. Below are the commands that you can use on you command line after installing Git Cli and configuring the same in the path.

Command prompt > cd <to the aspnetappl folder>

Command prompt > git init

Command prompt > git add –all

Command prompt > git commit –m “First Commit”

Above mentioned git commands will initialize the git repository locally in the application folder. And then add all the code in the folder to the local Git repository using the git add –all command.

Then commit the added files by using the git commit command, as shown above.

Now go to Oracle Developer Cloud project and create a Git repository for the .Net code to be pushed to. For the purpose of this blog I have created the Git repository by clicking the ‘New Repository’ button and named it as ‘DotNetDockerAppl’, as shown in the screenshot below. You may choose to name it as per your choice.

Copy the Git repository URL as shown below.

Then add the URL as the remote repository to the local Git repository that we have created using the below command:

 Command prompt > git remote add origin <Developer Cloud Git repository URL>

The use the below command to push the code to the master branch of the Developer Cloud hosted Git repository.

Command prompt > git push origin master


Deployment related files that need to be created:


This file will be used by the Docker Tool to build the Docker image with the .Net core installed and it would also include the .Net application code, cloned from the Developer Cloud Git repository. You will be getting the Dockerfile as part of the project. Please replace the existing Dockerfile script with the one below.

FROM microsoft/aspnetcore-build:2.0

# copy csproj and restore as distinct layers
COPY *.csproj ./

RUN dotnet restore

# copy everything else and build
COPY . ./
RUN dotnet publish -c Release -r linux-x64

In the above script we download the aspnetcore-build:2.0 image, then create a work directory where we copy the .csproj file and then copy all the code from the Git repo. Finally use the ‘dotnet’ command to publish the compiled code, compliant with linux-x64 machine.


This file is essential for the deployment of the .Net application on the Oracle Application Container Cloud.





 "command": "dotnet AspNetAppl.dll"


The command attribute in the json, specifies the dll to be executed by the dotnet command. It also specifies the .Net version to be used for executing the compiled code.



This file defines the build task and is being used by the Build file to identify the deployment artifact type that needs to be generated, which in this case is a zip file and also the files from the project that need to be included in the build artifact. For the .Net application we would only need to include everything in the publish folder including the manifest.json for Application Container Cloud deployment. The folder is defined in the src attribute as shown in the code snippet below.

    * http://usejsdoc.org/
  module.exports = function(grunt) {


    compress: {
      main: {
        options: {
          archive: 'AspNetAppl.zip',
          pretty: true
        expand: true,
        cwd: './publish',
        src: ['./**/*'],
        dest: './'

  grunt.registerTask('default', ['compress']);


Since Grunt is Nodejs based build tool, which we are using in this blog to build and package the deployment artifact, we would need the package json file to define the dependencies required for the Grunt tool to execute.

  "name": "ASPDotNetAppl",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "dotnet AspNetAppl.dll"
  "dependencies": {
    "grunt": "^0.4.5",
    "grunt-contrib-compress": "^1.3.0",
    "grunt-hook": "^0.3.1",
    "load-grunt-tasks": "^3.5.2"

Once all the code is pushed to the Git repository hosted on Oracle Developer Cloud. Below screenshot, shows how you can browse and verify your code by going to the Code tab and selecting the appropriate Git repository and branch in the respective dropdowns on top of the files list.


Build Job Configuration on Developer Cloud

Below are the build job configuration screen shows for the ‘DotNetBuild’ which will build and deploy the .Net application:

Create a build job by clicking on the “New Job” button. Give a name of your choice to the build job. For this blog I have named it as ‘DotNetBuild’. You will also need to select the Software Template which contains Docker and Nodejs runtimes. In case you do see the required software template in the dropdown,as shown in the screenshot below, you will have to configure the same from Organization -> VM Template menu. This will kick start the Build VM with the required software template. To understand and learn more about configuring VM and VM Templates you can refer this link.


Now go to the Builders tab where we would configure the build steps. First we would select execute shell where we would build the Docker image using the Dockerfile in our Git repository. Then create a container for the same (but not start the container). Then copy the compiled code to the build machine from the container and then use npm registry to download the grunt build tool dependencies. Finally, use the grunt command to build the AspNetAppl.zip file which will be deployed on Application Container Cloud.



Now configure the PSM Cli and configure the credentials for your ACCS instance along with the domain name. Then again configure Unix Shell builder where you will have to provide the psm command to deploy the zip file on Application Container that we have generated earlier using Grunt build tool.

Note: All this will be done in the same ‘DotNetBuild’ build job that we have created earlier.


AS part of the last part of build configuration, in the Post Build tab configure the Artifact Archiver as show below, to archive the generated zip file for deployment.


Below screen shot show the ‘DotNet’ application deployed on Application Container Cloud service console. Copy the application URL as shown in the screen shot. The URL will vary for your cloud instance.


Use the copied URL to access the deployed .Net application on a browser. It will look like as shown in the below screen shot.

Happy Coding!

**The views expressed in this post are my own and do not necessarily reflect the views of Oracle



Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.