0

Here's my file/folder structure:

 \
 |
 --RealLibrary\
 |  |
 |  --RealClass.cs
 |
 --SandboxFakesByHand\
    |
    --Fakes\
    |  |
    |  --RealLibrary.fakes
    |
    --Consumer.cs

The contents of RealClass.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RealLibrary
{
    public class RealClass
    {
        public string Name { get; set; }
    }
}

The contents of Consumer.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SandboxFakesByHand
{
    public class Consumer
    {
        public static void Method()
        {
            var a = new RealLibrary.Fakes.ShimRealClass();
        }
    }
}

The contents of RealLibrary.fakes

<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
  <Assembly Name="RealLibrary"/>
</Fakes>

Here's what I tried from the Developer Command Prompt for VS2012 (Premium) (starting in \RealLibrary\):

> csc /target:library RealClass.cs
> cd ..\SandboxFakesByHand
> csc /target:library Consumer.cs

The last one gives me an error of:

Microsoft (R) Visual C# Compiler version 4.0.30319.33440
for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.

Consumer.cs(13,25): error CS0246: The type or namespace name 'RealLibrary' could
        not be found (are you missing a using directive or an assembly
        reference?)

What I need to do to compile the Consume.cs file by hand?

Jesus is Lord
  • 14,971
  • 11
  • 66
  • 97

1 Answers1

4

You need to add a reference to your csc line:

csc /target:library /reference:..\RealLibrary\RealClass.dll Consumer.cs
carlpett
  • 12,203
  • 5
  • 48
  • 82
  • Thanks for the reply. That actually doesn't solve my issue as it doesn't generate the fakes assembly. Have you heard of Microsoft fakes before? – Jesus is Lord Mar 18 '14 at 13:29
  • 1
    @WordsLikeJared: I'm somewhat familiar with Fakes, yes. I didn't read your question well enough, however, I understood it as your problem being the compilation of the test after generating the fakes assembly. I haven't compiled fakes by hand myself and my current employer doesn't have a license so I can't test now, but this article (http://csharpening.net/?p=1381) should cover the necessary incantations (some powershell translation needed, though). Hope that helps, sorry about the confusion. – carlpett Mar 18 '14 at 14:11