TransMock.targets and deployment to non-development environment

Dec 7, 2016 at 1:53 PM
I'm using BTDF and in the btdfproj-file I'm using this import statement:
<Import Project="C:\Program Files (x86)\TransMock\BTS2013\Ext\TransMock.targets" />

This makes it impossible to deploy to an environment that doesn't have TransMock installed (e.g. system test and production environments).

Is there a good way to solve this?

Conditional import doesn't work in Visual Studio...
"While conditional import statements work in command-line MSBuilds, they do not work with MSBuild in the Visual Studio integrated development environment (IDE)."

I tried to include the targets file in the solution and copy it to the $(RedistDir) directory and import it from there <Import Project="$(RedistDir)\TransMock\BTS2013\Ext\TransMock.targets", but it didn't work.

Hope someone can help me.

Tore Bergset
Dec 10, 2016 at 4:25 PM
Hi Tore,

I've added the following condition to my Import statement. The means the Transmock.targets statement will only be imported if the machine has the BTDV_Env system environment variable set to 'Dev'.
<Import Project="C:\Program Files (x86)\TransMock\BTS2013R2\Ext\TransMock.targets" Condition="'$(BTDF_Env)' == 'Dev'" />

Dec 19, 2016 at 8:56 PM
Hi Tore and Rob! I recently stumbled across this very same issue myself and I figured out that this is not optimal at all. If you look at the TransMock.targets file I have added there a condition that is based on the file exported settings file name. THe purpose of this condition is to prevent that someone mockifies any other bindins but the ones for local development. However, this turns not to be a very good solution as the BTDF is already trying to import the project first before it reaches this line for evaluation.
Hence your suggestion Rob is excellent and if I may i will include it in the documentation. I will as well enhance the check in the targets file so that it is a bit more robust.
If you havent noticed i've just released version 1.2. I have left these changes for the next version as i am planning to introduce NuGet package which will make the integration of the framework even easier with VS.

Thanks and regards, Svetoslav