Fr0sT.Brutal 900 Posted January 13, 2023 (edited) I want to write build scripts for my projects with zero-config, i.e. any IDE options are untouched. I managed to run MSBuild and specify subfolders for pickup but stuck at defining Library path. I have several components from which I want compiler to take DCUs not sources so UnitSearchPath doesn't fit. But when I'm setting the variable via command line, it overrides default paths: msbuild /property:DelphiLibraryPath="d:\mycomp\lib" myproj.dproj >error F1027: Unit not found: 'System.pas' or binary equivalents (.dcu) Env variables should have saved the day but alas they seem not be expanded when assigned via command line msbuild /property:DelphiLibraryPath="$(BDSLIB)\$(Platform)\release;d:\mycomp\lib" myproj.dproj >error F1027: Unit not found: 'System.pas' or binary equivalents (.dcu) Is there any option to add some library paths to default list? I'm aware of \AppData\Roaming\Embarcadero\BDS\9.0\EnvOptions.proj file which is imported by all projects and contains DelphiLibraryPath definition but that's the last hope. If there was an option to import a file from command line, that would work too but I only found files with command line arguments. The 2nd workaround is to create local file with required options and manually import it inside all project files but I still hope for a better solution. Edited January 13, 2023 by Fr0sT.Brutal Share this post Link to post
programmerdelphi2k 237 Posted January 13, 2023 (edited) hi @Fr0sT.Brutal Sorry, I dont xpert in MSBuild ok, but you can try this way: testing with a project default: 1 form main, 1 other form define your options in your project in your project, if you dont, check the option: "Use MSBuild externally to compile" [x] now, use "BUILD" to build all files dependences (the most important will be "xxxxx.CMDS" file all another you can delete after!) not necessary at all now, you can see in your project folder a new file "<<project name>>.CMDS" in your "output directory" defined on project-options in my case, was copied the "RSVARS.bat" (from RAD \bin folder) file to the project directory to create the Delphi environment variables run it // this was important on task now, using "MSBuild.exe" appropriated, (in my case C:\Windows\Microsoft.NET\Framework\v4.0.30319>" version just executed: msbuild.exe on project folder, and the project will be created. folder opened on CMD console cd "C:\Windows\Microsoft.NET\Framework\v3.5>" or "C:\Windows\Microsoft.NET\Framework\v4.0.30319>" --- what "MSBuild.exe" you use? cd "D:\RADStudioTests\RADRX112Tests\__TEMP" command-lines on CMD console ( I'm in "d:" drive) c:msbuild.exe in my project I have defined Output directory = .\ExeOutput Unit output directory = .\DCUOutput DCP output directory = .\DCPOutput Use MSBuild externally to compile [x] Edited January 13, 2023 by programmerdelphi2k Share this post Link to post
Fr0sT.Brutal 900 Posted January 13, 2023 @programmerdelphi2k thanks for the tip, I didn't know about "Use MSBuild externally to compile" option. However, this won't help to solve the issue. Library paths are defined at IDE level and saved into shared file EnvOptions.proj in APPDATA what I'm trying to avoid. The most disappointing is that MSBuild doesn't expand $(..)-variables given to it in command line arguments Share this post Link to post
FredS 138 Posted January 13, 2023 11 minutes ago, Fr0sT.Brutal said: MSBuild doesn't expand $(..)- This is how I compile with older versions of controls.. might help you get started. The CMD file is in the project root and changes directory to Source: @ECHO OFF :: :: How to Redirect to an older Version of VCL :: Since no IDE is required this will work for NON installed versions of any VCL controls ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: :: Redirect DX, to compile with source we need to update all these ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: REM @SET DXVCL=%VCL%\DevExpress VCL\20.2.8 (26-May-2021) for PA2-R12 REM IF NOT Exist "%DXVCL%" ( REM echo."%DXVCL%", Directory does not exist REM Pause ) REM CALL :SetEnvVar "DXLibs" REM CALL :SetEnvVar "DXSources" REM SET DX REM pause :: :: Redirect UNI, to compile with source we need to update all these ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: REM @SET UNIVCL=%VCL%\UniDAC\9.0.1 (14-Sep-2021) REM IF NOT Exist "%UNIVCL%" ( REM echo."%UNIVCL%", Directory does not exist REM Pause ) REM CALL :SetEnvVar "UNILIB" REM CALL :SetEnvVar "UniSources" REM SET Uni REM pause :: :: Environmental Vars declared in the IDE must be redeclared ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @SET CompilerV=28 @SET ProductVersion=22.0 @SET IDEVER=11.0.2 :: :: Now expand those with rsVars.bat ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: call "C:\Program Files (x86)\Embarcadero\Studio\22.0\bin\rsvars.bat" :: :: Reset the rsVars.bat defaults ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @SET BDSCOMMONDIR=D:\Embarcadero Studio\22.0 :: :: Add the location of cmd.exe ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @SET PATH=%WINDIR%\System32;%PATH% cd source :: Recomended in 10.4 Release Notes.. MSBuild APP.dproj /t:clean REM TIMEOUT /T 10 MSBuild APP.dproj /t:build /v:q /p:Config=Release /p:platform=Win64 cd .. :: View any output notices pause :: ========== FUNCTIONS ========== EXIT /B :: Read a Value from Environment :: Param 1: Name of output variable. :: Param 2: SubKey. :RegQueryEnv @ECHO OFF SET KEY="HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" :: Remove the double quotes Set SUBKEY=%~2 FOR /F "skip=2 tokens=2,*" %%A IN ('reg.exe query %KEY% /v "%SUBKEY%"') DO ( set %1=%%B ) EXIT /B :: Expand any EnvVars in the Text :: Param 1: Name of output variable. :: Param 2: Text to Expand (%UNIVCL%\Lib\Delphi$(CompilerV)) :ExpandEnvVar @ECHO OFF set %1=%~2 REM echo.ExpandEnvVar=%Text% EXIT /B :: Combines RegQuery and ExpandEnvVar then uses @SET :: Param 1: SubKey. :SetEnvVar @ECHO OFF CALL :RegQueryEnv Value %1 CALL :ExpandEnvVar Value "%Value%" @SET %~1=%Value% 1 Share this post Link to post
Uwe Raabe 2057 Posted January 13, 2023 3 hours ago, Fr0sT.Brutal said: I have several components from which I want compiler to take DCUs not sources so UnitSearchPath doesn't fit. Have you actually tried to specify DCC_UnitSearchPath on the MSBuild command? msbuild /property:DCC_UnitSearchPath="d:\mycomp\lib" myproj.dproj 1 Share this post Link to post
programmerdelphi2k 237 Posted January 13, 2023 (edited) Note: when you "build" with "Use MSBuild..." on project, you'll have a file .CMDS with all properties necessary. then, I think that it's not necessary add it on command-line. You need just have in your "output EXE/DLL" folder of course, you can create this file manually! = <<project name>>.CMDS Quote -I"c:\radstudio\rx112\lib\Win32\debug" -I"c:\radstudio\rx112\lib\Win32\release" -I"C:\Users\WIn10H22\Documents\Embarcadero\Studio\22.0\Imports" -I"C:\Users\WIn10H22\Documents\Embarcadero\Studio\22.0\Imports\Win32" -I"c:\radstudio\rx112\Imports" -I"C:\Users\Public\Documents\Embarcadero\Studio\22.0\Dcp" -I"c:\radstudio\rx112\include" -O"c:\radstudio\rx112\lib\Win32\release" -O"C:\Users\WIn10H22\Documents\Embarcadero\Studio\22.0\Imports" -O"C:\Users\WIn10H22\Documents\Embarcadero\Studio\22.0\Imports\Win32" -O"c:\radstudio\rx112\Imports" -O"C:\Users\Public\Documents\Embarcadero\Studio\22.0\Dcp" -O"c:\radstudio\rx112\include" -R"c:\radstudio\rx112\lib\Win32\release" -R"C:\Users\WIn10H22\Documents\Embarcadero\Studio\22.0\Imports" -R"C:\Users\WIn10H22\Documents\Embarcadero\Studio\22.0\Imports\Win32" -R"c:\radstudio\rx112\Imports" -R"C:\Users\Public\Documents\Embarcadero\Studio\22.0\Dcp" -R"c:\radstudio\rx112\include" -U"c:\radstudio\rx112\lib\Win32\debug" -U"c:\radstudio\rx112\lib\Win32\release" -U"C:\Users\WIn10H22\Documents\Embarcadero\Studio\22.0\Imports" -U"C:\Users\WIn10H22\Documents\Embarcadero\Studio\22.0\Imports\Win32" -U"c:\radstudio\rx112\Imports" -U"C:\Users\Public\Documents\Embarcadero\Studio\22.0\Dcp" -U"c:\radstudio\rx112\include" in Project1.DPROJ is added: <DCC_UseMSBuildExternally>true</DCC_UseMSBuildExternally> <Import Project="$(MSBuildProjectName).deployproj" Condition="Exists('$(MSBuildProjectName).deployproj')"/> http://blog.blong.com/2017/10/delphi-buildinstall-to-android-from.html Edited January 13, 2023 by programmerdelphi2k 1 Share this post Link to post
programmerdelphi2k 237 Posted January 13, 2023 you can look the "detailed log" created by MSBuild using " /distributedFileLogger" = create a msbuild1.log file on project folder! Share this post Link to post
Fr0sT.Brutal 900 Posted January 16, 2023 On 1/13/2023 at 6:38 PM, Uwe Raabe said: Have you actually tried to specify DCC_UnitSearchPath on the MSBuild command? msbuild /property:DCC_UnitSearchPath="d:\mycomp\lib" myproj.dproj Arrrr! My bad! I always considered this option as path to sources but seems it works for DCUs as well! There are still some weird errors of kind "Unit was compiled with a different version" but at least compiler actually looks for DCUs in these paths. Share this post Link to post