2

I have a problem trying to shim HttpWebRequest. If you just add a fakes assembly of the System assembly it doesn't work instantly. However if you change the fakes file and add the specific namespace it works.

<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
  <Assembly Name="System" Version="4.0.0.0"/>
  <ShimGeneration>
    <Clear/>
    <Add FullName="System.Net.WebRequest!"/>
    <Add FullName="System.Net.HttpWebRequest!"/>
    <Add FullName="System.Net.HttpWebResponse!"/>
  </ShimGeneration>
</Fakes>

The problem is that this only works locally. The Automated build on the Team Foundation Server throws an error when trying to resolve ShimHttpWebRequest. It looks like the automated build ignores the fakes file, because when i build it manually with VS on the build server, it works.

Ruben-J
  • 2,663
  • 15
  • 33

2 Answers2

0

Go to the Assembly reference and add System.Net fake assembly. Double click on System.Net.Fake file and add below entries in System.Net.Fake file

<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/" Diagnostic="true">
<Assembly Name="System" Version="4.0.0.0"/>
<StubGeneration>
  <Clear/>
</StubGeneration>
<ShimGeneration>
   <Clear/>
   <Add FullName="System!"/>
   <Add FullName="System.Net!"/>
   <Add FullName="System.Net.WebRequest!"/>
   <Add FullName="System.Net.HttpWebRequest!"/>
   <Add FullName="System.Net.HttpWebResponse!"/>
 </ShimGeneration>
 </Fakes>
Tunaki
  • 132,869
  • 46
  • 340
  • 423
-1

I have same problem. Try commit to build-server also directory 'FakesAssemblies' in project home directory.