tags:

views:

99

answers:

2

We're building an C# .NET app which will be running on computers sitting inside trucks. We need to talk to Digital IO ports on the truck computers which do not exist on our developer machines, so I need to write a dummy library which will be included in our dev builds, but will be replaced with our actual Digital IO library when we do releases. And I want this library substitution to be automated by the build process.

Coming from a Java background, I can do this easily in maven using build profiles. Is there a similar way I can do it using MSbuild?? If not, whats the best way to handle this in C# microsoft land.

+1  A: 

I recently developed something similar where I assumed an interface for communicating with some embedded computers that operated servos. To write the software that controlled these computers I used Moq to mock the interfaces I wrote, and then later plugged in real classes via StructureMap that implemented those interfaces.

I also used Moq to write the unit tests for the software controlling the machine using the same interfaces.

cfeduke
Through use of StructureMap you won't have to worry about replacing a library during build - instead just have one of the MSBuild tasks replace the StructureMap portion of your App.config with the real configuration. It will work well for what you are attempting to do, I do this exact thing.
cfeduke
A: 

I would go for the IoC+Mock approach, but if u would like to do it with msbuild, take a look here for a great resource on conditions in msbuild

reshefm