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 off
setlocal
:: Configuration
set "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 exists
if exist "%LOGFILE%" (
echo Deleting old log file...
del "%LOGFILE%"
)
:: Launch Visual Studio with model automation
echo Launching Visual Studio with model automation...
"%DEVENV%" "%SLNFILE%" MODELAUTOMATION="%MODELFILE%"
:: Wait for Visual Studio to close (optional)
:: timeout /t 30 >nul
:: Display log file contents
echo.
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