xsharp.eu • How to setup an Automated Build Pipeline
Page 1 of 1

How to setup an Automated Build Pipeline

Posted: Sat Dec 11, 2021 9:43 pm
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.

How to setup an Automated Build Pipeline

Posted: Sun Dec 12, 2021 7:08 am
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

How to setup an Automated Build Pipeline

Posted: Sun Dec 12, 2021 10:27 am
by hilberg.it
Sounds good. Thank you!

How to setup an Automated Build Pipeline

Posted: Sun Dec 12, 2021 4:48 pm
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.

How to setup an Automated Build Pipeline

Posted: Mon Dec 13, 2021 11:23 pm
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)'

How to setup an Automated Build Pipeline

Posted: Tue Dec 14, 2021 6:58 am
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

How to setup an Automated Build Pipeline

Posted: Tue Dec 14, 2021 1:48 pm
by hilberg.it
Hey, I created a Gist with the build pipeline and integrated your suggestions. No changes to project files needed anymore. HTH

How to setup an Automated Build Pipeline

Posted: Sun Jun 18, 2023 7:34 am
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/.