title: Generate Microsoft Fakes assemblies in .NET 5
body: <p>I am working on migrating .NET 4.x code onto .NET 5. The unit test projects make extensive use of of Microsoft Fakes, which recently gained an official implementation for .NET 5 with Visual Studio 2019. I have the build and unit tests running locally and started setting up a CI/CD pipeline for the project in AzureDevOps (On Prem ). I have VS 2019 Enterprise installed locally and on the build agent server</p>
  <p>My build pipeline consists of a <code>dotnet restore</code> with the following options<br />
  <code>-s https://api.nuget.org/v3/index.json -s &quot;C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\&quot;</code></p>
  <p>I've included the <code>&quot;C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\&quot;</code> as a source since I have determined that Microsoft fakes is local nuget package that gets installed by VS 2019 enterprise edition in this specific directory.</p>
  <p>After the restore are two <code>dotnet build</code> commands run with the following options<br />
  <code>--no-restore --configuration $(BuildConfiguration)  /p:VersionPrefix=$(Build.BuildNumber) /p:AssemblyVersion=$(Build.BuildNumber)  /p:GenerateProjectSpecificOutputFolder=True</code></p>
  <p>I'm using 2 <code>dotnet build</code> commands because I noticed that the way I had the task set up using one command was causing the Test projects to be built before the project they were testing and didn't want to  spend time on finding a glob pattern to set the the build order correctly. (Or I was misreading the logs,  either way I split it out for clarity while debugging)</p>
  <p>When the <code>dotnet build</code> command runs for the test project, it fails with the message <code> The type or namespace name 'Fakes' does not exist in the namespace (are you missing an assembly reference?)</code>. This tells me that the Fakes assemblies I have in the test projects are not getting generated by <code>dotnet build</code> (or at least with the options I have currently). What do I need to do in order to generate the Fakes assemblies?</p>
  <p>Misc: I am using the 1.x version of the .NET CORE task in azure dev ops.</p>
  <h3>Update 1</h3>
  <p>After a suggestion in another forum, running the relevant <code>dotnet</code>  commands on my local workstation also produced the same error. At the request of another  Here is a breakdown</p>
  <p><code>dotnet build .sln --configuration Debug /p:GenerateProjectSpecificOutputFolder=True</code>
  worked locally, but I realized that I still had the fakes assemblies from the last time I built the sln in Visual Studio. So then tried</p>
  <p><code>dotnet clean</code>
  <code>dotnet build .sln --configuration Debug /p:GenerateProjectSpecificOutputFolder=True</code>
  which errored out with the <code>Fakes does not exist</code> error. I then tried</p>
  <p><code>dotnet clean</code>
  <code>dotnet build Main.csproj --configuration Debug /p:GenerateProjectSpecificOutputFolder=True</code>
  <code>dotnet build Main.Tests.csproj --configuration Debug /p:GenerateProjectSpecificOutputFolder=True</code></p>
  <p>The build of Main.csproj was successful while the build of Main.Tests.csproj errored out with <code>Fakes does not exist</code></p>
  <p><code>dotnet clean</code>
  <code>dotnet restore</code>
  <code>dotnet build .sln --configuration Debug --no-restore /p:GenerateProjectSpecificOutputFolder=True</code>
  also gives the <code>Fakes does not exist</code> error</p>
  <p>according to <code>dotnet nuget list source</code> I am pulling packages from the following sources</p>
  <pre><code>1.  nuget.org [Enabled]
      https://api.nuget.org/v3/index.json
  2.  &lt;Internal Nuget Feed 1&gt; [Enabled]
        &lt;Details Redacted&gt;
  3.  DevExpress 19.1 Local [Enabled]
    C:\Program Files (x86)\DevExpress 19.1\Components\System\Components\Packages
  4.  Microsoft Visual Studio Offline Packages [Enabled]
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
  5.  &lt;Internal Nuget Feed 2&gt; [Enabled]
       &lt;Details Redacted&gt;
  </code></pre>