-=//mawi.org//=-
 Thursday, July 20, 2006
(or "MSBuild sucks at solutions - one simple proposal you can try")

MSbuild is a product with some great advantages, the foremost being the flawless IDE integration. However, it does have some weaknesses - one being the weak solution story.

Sample of stuff you cannot do with MSBuild without resorting to hacks:

- Theres no story for executing something just before a compile actually happens
- You cannot set up anything to happen at the end of a solution build
- The API (object model) is weak, you cannot even get a hold of the currently executing project (!).
From there on it just gets worse.

This is by design - you are not supposed to operate on the context and there seems to be no way to set up any state for the currently executing solution build.

The solution story is very weak, it generates a project in memory from the old syntax, and you cannot really access it - to set up solutionwide properties, imports, hook into the process, etc.

The general idea of having a very clear and limited interface towards tasks is naturally good, and would work if the solution story was stronger - and in line with the rest of the design. Since it is this way however, many things prove difficult to accomplish.

Ugly hack it! There have been proposed solutions using wrappers, but those are unusable in the IDE, which again really is the forté of msbuild. If we don't get IDE integration there are other solutions (SCONS, rake) that beat msbuild with one hand behind their backs. So one option is to put state into environment vars (pretty, aint it - gets that 80's smell back into the room). If you want static properties you can meddle with the files in the framework (system) directory, but in many companies that is not a tolerated option.

When confronted by a problem such as this, I usually have faith in the designers and start researching - banging my head against the wall trying to find an appropriate solution. This time was no different. Then comes the realization phase that there is actually no way forward by means of the intended uses. You step back...

My proposed solution is simple; for me the problem was essentially twofold - I wanted to be able to keep state that all projects could share over the course of a solution build, and I wanted to hook into the start and end of the solution build process. My idea: Create a singleton that stores state over the life of the appdomain and a set of tasks that allow the projects to interact with it.

1. For state there are tasks that allow you to get and set data
2. For hooks there is an initialized flag and a task to set it as you set data, and then there is a task by which you may retrieve the value of the flag.

In order to use this alternative, you are only required to put an import into each project file - which seems to be the standard and least obtrusive way of mopdifying the build process (analoguous to MSBee).

Note that this is still a hack! Why? First, it doesnt adhere to the design of MSBuild, with very clearcut interfaces between tasks, targets, etc (although, that is the problem since MSBuild is half baked, see above). Second, the end-of-solution targets are called from a destructor - which is bad (read up on who executes the destructor and how to find out why it is bad, save for the fact that it is conceptually bad). So this is at best an interim way to get things done - the first thing I could think of.

The best way to see how this works is to download the src zip, and open it up in visual studio (or just review the example test solution). It has a test solution that you can run (F5) and examine it to see how to use this little piece of code.

Please get back to me if there are bugs, improvements or maybe better/cleaner ways of accomplishing what I want.

Known issues: No logging when "end of solution" target runs.

SolutionUtilTasksSrc.zip (128.36 KB)

SolutionUtilsBin.zip (11.23 KB)
7/20/2006 10:52:29 AM (Romance Daylight Time, UTC+02:00)  #    Comments [2]  |  Trackback
Related Posts:
DevSummit 2006 Talk Materials
MsBuild VS.NET 2003 Conversion task

Tracked by:
http://9ov-information.info/90732018/index.html [Pingback]
http://9oy-information.info/65750366/free-internet-bandwidth-meter.html [Pingback]
http://9on-information.info/63132556/index.html [Pingback]
http://9oy-information.info/56892639/pretty-paint-horse.html [Pingback]
http://9om-information.info/08079508/cruel-music-junebug-blog.html [Pingback]
http://9oy-information.info/57605195/index.html [Pingback]
http://9pt-free-porn.info/46697510/index.html [Pingback]
http://9oj-information.info/93315573/kappa-crossword-puzzle-books.html [Pingback]
http://9on-information.info/15410391/what-is-job-specification-.html [Pingback]
http://9qq-information.info/19232616/index.html [Pingback]
http://9qf-information.info/35406179/lavorint-campobasso.html [Pingback]
http://9pn-free-porn.info/28116533/head-ass-anal-good-amateur.html [Pingback]
http://9rv-information.info/61682187/index.html [Pingback]
http://9rk-information.info/28964160/index.html [Pingback]
http://9si-information.info/65380483/integratore-alimentare-sito.html [Pingback]
http://9rw-information.info/92449571/index.html [Pingback]
http://9rh-information.info/40800478/index.html [Pingback]
http://9rk-information.info/66304938/index.html [Pingback]
http://9rd-information.info/11984424/index.html [Pingback]
http://9rm-information.info/50622088/video-games-for-girls-playstation-3.html [Pingback]
http://9uaas-free-porn.info/01747804/index.html [Pingback]
http://9uaae-free-porn.info/43103061/index.html [Pingback]
http://9tm-free-porn.info/28937129/picardie-france.html [Pingback]
http://9uabj-free-porn.info/42309628/free-porn-hentia.html [Pingback]
http://9uaah-free-porn.info/59476246/teen-boys-bedroom-decorating-ideas.html [Pingback]
http://9uabm-free-porn.info/71523067/personal-loan-analysis.html [Pingback]
http://9uabm-free-porn.info/90730205/candy-apples-photos-porn.html [Pingback]
http://9uach-free-porn.info/84421108/index.html [Pingback]
http://9uafs-le-informazioni.info/58425302/ostello-roma-termini.html [Pingback]
http://9uaem-le-informazioni.info/73914471/aldo-shoes.html [Pingback]
http://9uaef-le-informazioni.info/88257912/index.html [Pingback]
http://9uafm-le-informazioni.info/61254303/associazione-felina.html [Pingback]
http://9uaeh-le-informazioni.info/47496412/index.html [Pingback]
http://9uafj-le-informazioni.info/76461312/desktop-matrix.html [Pingback]
http://9uafa-le-informazioni.info/65792866/toledo-catedral.html [Pingback]
http://9uaef-le-informazioni.info/80021680/u2-dvd-rattle-and-hum.html [Pingback]
http://9uafg-le-informazioni.info/28134758/legge-15-luglio-2002.html [Pingback]
http://9uahf-le-informazioni.info/73041574/index.html [Pingback]
http://9uahr-le-informazioni.info/80453361/rosa-dei.html [Pingback]
http://9uahk-le-informazioni.info/74847820/green-fee-sconto-scontato.html [Pingback]
http://9uahb-le-informazioni.info/82398030/parco-area-protetta-lombardia.html [Pingback]
http://9uagh-le-informazioni.info/08949418/global-lifts-company-srl.html [Pingback]
http://9uaho-le-informazioni.info/79032671/index.html [Pingback]
http://9uahd-le-informazioni.info/99602736/index.html [Pingback]
http://9uahj-le-informazioni.info/05557242/index.html [Pingback]
http://9uala-free-porn.info/07309643/pamela-anderson-geting-fucked.html [Pingback]
http://9uakf-free-porn.info/86103053/index.html [Pingback]
http://9uaia-free-porn.info/66514482/index.html [Pingback]
http://9uako-free-porn.info/02349368/index.html [Pingback]
http://9ualr-free-porn.info/43547525/gay-dominate.html [Pingback]
http://9ualg-free-porn.info/72814535/index.html [Pingback]
http://9uale-free-porn.info/09364051/index.html [Pingback]
http://9ualg-free-porn.info/78009040/index.html [Pingback]
http://9ualc-free-porn.info/34652078/index.html [Pingback]
"Life" (Life mawiorg) [Trackback]