I want to implement a fairly basic build process, and I know I could do it with batch files calling MSBuild, however I want to make it fairly dynamic, and more importantly, I want to be able to capture the results when MSBuild runs.

I want to implement a fairly basic build process, and I know I could do it with batch files calling MSBuild, however I want to make it fairly dynamic, and more importantly, I want to be able to capture the results when MSBuild runs.

I've had a shot at running MSBuild using CreateProcess, however it apparently runs horrendously slow compared to doing it from the command line.

I'm wondering whether it is worth using TJclClrHost from JCL to host the .NET runtime to, and/or to import the MSBuild .NET assembly (I haven't done anything like that in ages), or whether there's some other way of capturing the results of MSBuild?

Before anyone makes the suggestions, I've already considered tools like FinalBuilder, Jenkins etc. This is something I'd like to explore for myself.

Comments

  1. Can you point me to the part where I'm able to capture the result of MSBuild myself? (i.e. without Continua CI) That's really the key

    ReplyDelete
  2. David Nottage The burning question would be, why? It's different for every version of delphi (subtle, undocumented changes), I deal with this stuff every day, and it's 20+ years of hard earned knowledge.

    BTW, hosting the CLR is not for the faint at heart (we do it in FinalBuilder), as it's "all about da COM" and pretty easy to end up in deadlock territory (and delphi lacks the means to detect them).

    Unless this is your core business, I'd just pick a tool (be that FinalBuilder, Jenkins, Continua CI or whatever, I'm not running a sales pitch here) and spend more time on your actual projects.

    ReplyDelete
  3. Vincent Parrett As to the "why?": so I can examine what the results are, and what I need to do to resolve them. My goal is to have a (somewhat) automated process for doing builds, that I can kick off on demand, or have start under certain conditions (like when some files have changed, but not necessarily any file in a folder or folders). I want to be able to point this process at nominated projects and/or groups without having to worry about integrating with version control, and with dead simple configuration. Most CI tools I've looked at are way too complex for my needs. At the moment I'm better off using batch files and examining the output.

    ReplyDelete
  4. One of our internal tools called msbuildfilter captures the compiler output by calling create process. I haven't noticed any slow down, but I must admit that I didn't do any timing.

    ReplyDelete
  5. Thomas Mueller It may well be that I need to use a flag or setting that will make it "go faster". Do you have an example of how you call it?

    ReplyDelete
  6. This CreateProcess slow down is FUD.

    ReplyDelete
  7. David Nottage I just checked: The program does not start msbuild, instead it is reading its output piped to it via the following command line:

    msbuild project.droj /t:build | msbuildfilter some parameters

    So, I can't say anything about CreateProcess slowing down the process or not.

    ReplyDelete
  8. I've switched to using TJvCreateProcess from the JVCL and it's way faster, so guess there is some deficiency in the code I was using.

    ReplyDelete
  9. There's a MSBuild API that might help you. See e.g. bogdangavril.wordpress.com - Take control of MSBuild using MSBuild API . Unfortunately I haven't found Delphi samples using it.

    ReplyDelete
  10. What we usually do is by-passing MSBuild, and let the batch call the dcc*.exe command line compilers with the right switches. This is what MSBuild does, in fact. ;) For resources, we create our own .res files either during the batch, or using .rc files generated by some tools written in Delphi. It allows us to share easily the build process with FPC, for Linux and BSD compilation.

    ReplyDelete
  11. A. Bouchez That's fine, but if you are already using msbuild, why would you want to maintain two distinct build processes?

    ReplyDelete
  12. David Heffernan You are right. From my personal taste and (painful) experiment, I tend to keep away from build systems like MSBuild or ANT, in favor to small scripts (bat or python) or small Delphi command line executables (which are in fact easy to debug and interact with existing Delphi code, e.g. if you want to generate wrappers or documentation for your services).

    ReplyDelete
  13. Vincent Parrett Need not to say FB is great, the reasons for DIY would be "keep things *completely* under control and transparent, and to keep things as simple as possible".

    ReplyDelete

Post a Comment