chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
In the Beta Support forum, I wrote https://www.typemock.com/community/viewtopic.php?t=119

I've now tried to get TypeMock to run in a Team Build environment, but keep getting the "MockInserter not running, please run 'mocking_on.bat' before running the tests." error.

My TFSBuild.proj file looks like this:

<Target Name="BeforeTest">
<Exec Command="Mocking_on.bat" WorkingDirectory="C:Program FilesTypeMock.NET" />
</Target>

<Target Name="AfterTest">
<Exec Command="Mocking_off.bat" WorkingDirectory="C:Program FilesTypeMock.NET" />
</Target>

and the batch files are being executed, but it doesn't seem to affect the build.

Is there any way to get native VS2005 tests to run correctly within the context of Team Build?
asked by thepuffin (2.4k points)

2 Answers

0 votes
Typically, I have the answer to the question!

Instead of running a batch file to set the environment variables, use a custom MSBuild task to do it for you:

 public class SetEnvVar : Task
    {
        private string _variable;
        private string _value;

        [Required()]
        public string Variable
        {
            get { return _variable; }
            set { _variable = value; }
        }

        [Required()]
        public string Value
        {
            get { return _value; }
            set { _value = value; }
        }

        public override bool Execute()
        {
            Environment.SetEnvironmentVariable(_variable, _value);
            return true;
        }
    }


<Target Name="BeforeTest">
<SetEnvVar Variable="Cor_Enable_Profiling" Value="0x1" />
<SetEnvVar Variable="COR_PROFILER" Value="{B146457E-9AED-4624-B1E5-968D274416EC}" />
</Target>

<Target Name="AfterTest">
<SetEnvVar Variable="Cor_Enable_Profiling" Value="0x0" />
</Target>
answered by thepuffin (2.4k points)
0 votes
Thanks alot for sharing this.
Very Cool 8)
answered by scott (32k points)
...