Continuous integration (CI) is the process where the build/evolve/deploy process is automated but tools.
One aspect of Continuous integration is the ability to apply additional data changes that may be needed for a complete deploy and to handle this need in a CI environment we have the Documentation:ScriptAfterEvolve functionality of MDrivenServer.
But what also is needed is to do the following steps via automation/script:
- Generate all code - to ensure the code maps 100% to the model
- Rebuild all - to ensure that assemblies are correctly build prior to upload for use with CodeDress
- Upload to MDrivenServer - to initiate the evolve och the database
A few news has been added to the MDrivenFramework extension of VS2022 to facilitate these steps.
An example script can be found in our GitHub respository: supportMDriven\MDrivenComponents\MDrivenTurnkeyComponents\Samples\Automation\LaunchVSWithModelCodeGenFullBuildAllAndUploadToMDrivenServer.cmd
The script looks like this:
@echo offsetlocal:: Configurationset "MODELAUTOMATION_URL=TheUrlToTheMDrivenServer"set "MODELAUTOMATION_USER=TheAccountForMDrivenServer"set "MODELAUTOMATION_PWD=ThePWDForMDrivenServer"set "LOGFILE=C:\Users\hkarlsen\source\repos\MDriven Solution Template1\MDRIVENAUTOMATIONRESULT.log"set "MODELFILE=C:\Users\hkarlsen\source\repos\MDriven Solution Template1\MDriven Solution Template1\MDrivenEcoSpaceAndModelNetStandard\MDrivenModel.ecomdl"set "SLNFILE=C:\Users\hkarlsen\source\repos\MDriven Solution Template1\MDriven Solution Template1.sln"set "DEVENV=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe":: Delete old log file if it existsif exist "%LOGFILE%" (echo Deleting old log file...del "%LOGFILE%"):: Launch Visual Studio with model automationecho Launching Visual Studio with model automation..."%DEVENV%" "%SLNFILE%" MODELAUTOMATION="%MODELFILE%":: Wait for Visual Studio to close (optional):: timeout /t 30 >nul:: Display log file contentsecho.echo ===== Automation Result =====if exist "%LOGFILE%" (type "%LOGFILE%") else (echo Log file not found: "%LOGFILE%"")endlocal
You will need to wake up VS with the solution ("%SLNFILE%" standard) and the model (MODELAUTOMATION="%MODELFILE%")
Prior to starting VS you must set the following env-vars:
MODELAUTOMATION_URL
MODELAUTOMATION_USER
MODELAUTOMATION_PWD
A fileMDRIVENAUTOMATIONRESULT.log will be produced once VS is finished and auto quits
To successfully use this you must have the MDrivenFramework - extension installed in your VS2022. Get the vsix from the download page at MDriven.net
Alternatively
Alternatively you may set this environment variable:
MODELAUTOMATION_PACKAGEONLY=true
A file ModelAndCodeForMDrivenServer.zipis then produced (in current directory) along with the MDRIVENAUTOMATIONRESULT.log
The zip file is what the MDrivenServer expects on this endpoint:
<YourMDrivenServerUrl>/api/ServiceAdmin_WebApi/SubmitNewModelCI
Post with Multipart content and basic auth (Authorization header with Basic + base64(username:pwd))
