Oracle Visual Builder Studio includes a wide range of software you can use to build and package applications written in some of today's most popular languages, Microsoft .Net is one that is not included by default.
This short post will walk you through the steps to create a build environment for  Microsoft ASP .Net application in Visual Builder Studio using a Docker based executor.

Before you Begin

You will need the following tools installed on your local machine and a basic understanding of how to use them.

You will be starting from scratch and create the software as you go.

Create a Build Executor

The example application used in this post will be the basic "hello world" application created when you start a dotnet project. All you need in your executor is the dotnet SDK and Git.

Follow the steps in this post to create a new executor, but use the following Dockerfile and name the new executor dot_net_executor.

FROM  oraclelinux:8.6

RUN dnf install git dotnet-sdk-6.0 -y

  This Dockerfile will start from an Oracle Linux 8.6 image then it will install git and the dotnet sdk in your new executor.  If your project needs more tools than the SDK and Git, modify the Dockerfile to include them.

Git Repository

Your application will be stored in a new Git repository in Visual Builder Studio.

New Git Repository

  • Open Visual Builder Studio.
  • Switch to the Project Home section.
    • Select your project (or create a new one)
  • Click Create Repository

Git Repository details

  • Name your repository HelloWorldDotNet.
  • Set the initial content to Empty repository.
  • Click Create.

Use Git to clone the new empty repository to your local machine.

Git repo url

  • Click the Clone Button.
  • Click the Copy URL button.  (Both HTTPS and SSH are available to choose from.)

On your local machine (examples are in a Linux environment):

  • Open a terminal.
  • Choose a directory to work in.
  • Type git clone followed by your copied URL.
git clone ssh://idcs-biglongstring/HelloWorldDotNet.git

If you have issues with git clone, make sure you have configured your environment correctly.

Create a new dotnet app in the HelloWorldDotNet directory.

dotnet new console -o HelloWorldDotNet -f net6.0

Change into the HelloWorldDotNet directory

cd HelloWorldDotNet

Create a .gitignore file that will ignore the bin directory.

echo bin >> .gitignore

Publish the app.

dotnet publish

Run it to make sure everything works.

$ dotnet run bin/HelloWorldDotNet
Hello, World!

Now that you have a basic "hello world" app, push it up to the Visual Builder Studio git repository.

git add .
git commit -m "initial commit"
git push

Your git repository should now look similar to this.

After git push

Time to create a build job.

Build and Package

New Job

  • Switch to the Builds section.
  • Click Create Job.
  • Name it BuildPackageDotNet.
  • Select your dot_net_executor template.
  • Click Create.

Git Tab

Add git

  • Open the Git tab.
  • Click Add Git / Git.

Git details

  • Select the HelloWorldDotNet.git Repository
  • Check the box next to Automatically perform build on SCM commit

Steps

Add step

  • Switch to the Steps tab.
  • Click Add Step.
  • Select Common Build Tools / Unix Shell.

Enter the following script.

dotnet publish

cd bin/Debug/net6.0/publish/

zip -rq $WORKSPACE/HelloWorldDotNet.zip *

After Build

Add after action

  • Switch to the After Build Tab.
  • Click Add After Build Action.
  • Select Artifact Archiver.

After details

  • In Files to archive enter *.zip.
  • Click Save.

Build Now

Click Build Now.

This will:

  • Add your new job to the build queue.
  • The system will spin up a build executor from your Docker image.
  • Your application will be pulled from your Git repository inside the executor.
  • The commands in the steps tab will be executed.
    • Publishing your application.
    • Creating a zip file from the published application.
  • The zip file will be archived to the build job.

You can download a copy of the zip file by clicking the Artifacts button on the job details page.

View build log

Click on the View build log button to see that the dotnet publish command was successful.

Build log

You can use this same process to create other executors as needed. You don't need to use the same executor for all of the build jobs in a pipeline.

Next steps you could try:

As you grow your application, you can modify the Docker image to accommodate any needed changes.  The Create a Docker Executor post includes instructions for recreating the executor.

Helpful links: