This project is read-only.

TransMock.targets and deployment to non-development environment

Dec 7, 2016 at 2: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...
(https://msdn.microsoft.com/en-us/library/92x05xfs.aspx
"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.

Regards,
Tore Bergset
Dec 10, 2016 at 5: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'" />
Regards,

Rob.
Dec 19, 2016 at 9: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
Aug 4 at 8:37 AM
Hi Tore and Rob, i have just released version 1.3 of TransMock. Please take a look at the post about that in the Discussions for further instructions on how to make use of it. Hope you find it handy as i have adressed the issue you have flagged above.
Cheers, Svetoslav