About Me

My photo
I am MCSE in Data Management and Analytics with specialization in MS SQL Server and MCP in Azure. I have over 13+ years of experience in IT industry with expertise in data management, Azure Cloud, Data-Canter Migration, Infrastructure Architecture planning and Virtualization and automation. Contact me if you are looking for any sort of guidance in getting your Infrastructure provisioning automated through Terraform. I sometime write for a place to store my own experiences for future search and read by own blog but can hopefully help others along the way. Thanks.

Deploy .NET Application using CI/CD

using YAML files to define the build environment is a common approach when setting up a build pipeline for a .NET project. This can be done using a tool like Azure DevOps, which allows you to define your build pipeline using a YAML file called azure-pipelines.yml.

Here is an example of a YAML file that sets up the build environment for a .NET Core project:

# define the build environment

pool:

  vmImage: 'windows-latest'

# define the build steps

steps:

- task: UseDotNet@2

  inputs:

    version: '3.1.x'

- script: dotnet build --configuration Release

  displayName: 'dotnet build'


# define the build environment

pool:

  vmImage: 'windows-latest'


# define the build steps

steps:

- task: UseDotNet@2

  inputs:

    version: '3.1.x'

- script: dotnet build --configuration Release --framework netcoreapp3.1

  displayName: 'dotnet build'


you can use YAML files to configure the build process for a .NET project in Azure DevOps.

In this example, the dotnet build command is run with the --configuration Release and --framework netcoreapp3.1 flags. 


The --configuration flag specifies the build configuration (e.g. Release or Debug), and the --framework flag specifies the target framework for the project (e.g. netcoreapp3.1, net5.0, netstandard2.0 etc).


You can also use the YAML file to configure other build options as well. For example, if you are using a specific version of a library, you can install that version by adding a step for nuget install command.


It's important to note that you can customize the pipeline to meet your requirements, and you can add more steps to your pipeline as per your project requirements.



# define the build environment

pool:

  vmImage: 'windows-latest'

# define the build steps

steps:

- task: NuGetCommand@2

  inputs:

    command: 'install'

    packagesToInstall: 'Newtonsoft.Json'

    version: '12.0.3'

- task: UseDotNet@2

  inputs:

    version: '3.1.x'

- script: dotnet build --configuration Release --framework netcoreapp3.1

  displayName: 'dotnet build'


In this example, the NuGetCommand@2 task is used to install the Newtonsoft.Json package with version 12.0.3. This is added as the first step in the pipeline, before the dotnet build command is run.

It's important to note that, you can install multiple packages by providing comma separated package names. Also, you can use wildcard (*) to install packages with specific version pattern.

It's worth noting that the above example is just one way to install NuGet packages, you can use other alternatives as well such as Nuget.exe command line.

It's also worth noting that you can customize the pipeline to meet your requirements and you can add more steps to your pipeline as per your project requirements.

No comments: