How to setup an Automated Build Pipeline

This forum is meant for anything you would like to share with other visitors
Post Reply
hilberg.it
Posts: 75
Joined: Sun Sep 20, 2020 7:25 am
Location: Germany

How to setup an Automated Build Pipeline

Post by hilberg.it »

Hi,
I am wondering what would be a good idea to setup an automated build pipeline for a X# project. I am trying to decide which approach would be most promising:
a) setup a vm as development server in the cloud and install vs, x# here manually. Trigger build script with msbuild. Problems: Rather expensive. How should a build be triggered? Commit Hook?
b) Since x# builds on .Net Core 5+ would it be a good idea to port the project to .Net5 and use something like Azure .NET Core CLI task?

Does anyone have experience with automated builds and likes to share some pros and cons? What are other setups?
Thanks.
User avatar
robert
Posts: 4518
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

How to setup an Automated Build Pipeline

Post by robert »

You do not need to install VS to install X#.
X# also detects and integrates in the VS Build tools

And we're also working on a Nuget package for the X# compiler, so all you would have to do is add the X# compiler package to your projects to build them.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
hilberg.it
Posts: 75
Joined: Sun Sep 20, 2020 7:25 am
Location: Germany

How to setup an Automated Build Pipeline

Post by hilberg.it »

Sounds good. Thank you!
VR
Posts: 102
Joined: Sun Aug 23, 2020 3:07 pm
Location: Italy

How to setup an Automated Build Pipeline

Post by VR »

We created automated builds for our x# solutions. We are currently using an OnPremise Jenkins Server to run the builds but since we use Azure Devops as Repository, we plan to switch to Azure Pipelines in the future.

Early in the process, we decided to use Nuke.Build to create our "build-scripts". Nuke is a build automation solution based on .Net5. The scrips are written in c#. I like Nuke, because I can debug the scripts easily and run them using any build server or even on local machines.

If your builds are more complex than "running msbuild with some parameters", than Nuke is worth a look. An alternative might be cake.build.
hilberg.it
Posts: 75
Joined: Sun Sep 20, 2020 7:25 am
Location: Germany

How to setup an Automated Build Pipeline

Post by hilberg.it »

TWIMC: I also want to use Azure DevOps for CI tasks. Here is what I came up with so far. Seems to serve my needs :)
1) copy XSharp compiler to my repo
2) add Precompiler Include Path

Code: Select all

<IncludePaths>$(SolutionDir)XSharpInclude</IncludePaths>
and XSharp DLL HintPaths e.g.

Code: Select all

<HintPath>..XSharpAssembliesXSharp.Core.dll</HintPath>
to *.xsproj files
3) set some vars in azure-pipelines.yml

Code: Select all

trigger:
- main

pool:
  vmImage: 'windows-2019'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
  XSharpMsBuildDir: '$(Build.SourcesDirectory)/XSharp/MsBuild'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'
    
- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
        Write-Host "##vso[task.setvariable variable=PATH;]${env:PATH};$(Build.SourcesDirectory)XSharpBin"
        $RegistryPath = 'HKLM:SoftwareWOW6432NodeXSharpBVXSharp'
        $Name         = 'XSharpPath'
        $Value        = '$(Build.SourcesDirectory)XSharp'
        If (-NOT (Test-Path $RegistryPath)) {
          New-Item -Path $RegistryPath -Force | Out-Null
        }  
        New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -PropertyType String -Force
    
- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
User avatar
robert
Posts: 4518
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

How to setup an Automated Build Pipeline

Post by robert »

You do not have to change the project file to set an include path. You can also set the INCLUDE environment variable.
And for the DLL path you can set the LIB environment variable.
And indeed the path to the BUILD support files is read from the XSHARPMSBUILDDIR.

And guys, if you have this working. Are you willing to share this with us, so we can setup automated builds of the X# runtime and VS Integration in Github ?

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
hilberg.it
Posts: 75
Joined: Sun Sep 20, 2020 7:25 am
Location: Germany

How to setup an Automated Build Pipeline

Post by hilberg.it »

Hey, I created a Gist with the build pipeline and integrated your suggestions. No changes to project files needed anymore. HTH
Lesteraction
Posts: 1
Joined: Mon Mar 27, 2023 4:55 pm

How to setup an Automated Build Pipeline

Post by Lesteraction »

What approach would be the best for setting up an automated build process for an X# project? I'm attempting to decide which strategy would be the most fruitfulhttps://overplugged.org/.
Post Reply