title: Type Conflict While Writing NUnit Tests
body: <p>I am getting the below warning in VS Code while writing Unit Tests with NUnit:</p>
  
  <p><em>The type 'MyClass' in 'MyProject.cs' conflicts with the imported type 'MyClass' in 'MyProject, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'Myproject\Tests\MyClass.cs'. (CS0436) [Tests]</em></p>
  
  <p>These are the steps I took so far:</p>
  
  <ol>
  <li><p>Navigated to my desired folder for all C# projects (e.g. <code>E:\MyCSharpProjects</code>).</p></li>
  <li><p>Created a new C# Console Project via <code>dotnet new console -o MyProject</code>.</p></li>
  <li><p>Wrote some code.</p></li>
  <li><p>Ran the following command once: <code>dotnet new -i NUnit3.DotNetNew.Template</code>. I assume this installs NUnit project templates.</p></li>
  <li><p>Created a new folder inside <code>MyProject</code>'s root folder called <code>Tests</code>.</p></li>
  <li><p>Navigated inside the new <code>Tests</code> folder and ran the following commands:</p>
  
  <p><code>dotnet new nunit</code></p>
  
  <p><code>dotnet add reference ../MyProject.csproj</code>       </p></li>
  <li><p>Installed the <code>NUnit</code> package via NuGet on <code>MyProject.csproj</code>.</p></li>
  <li><p>Wrote some test code.</p></li>
  </ol>
  
  <p><strong>NOTE 1:</strong> For both <code>MyProject.csproj</code> and <code>Tests.csproj</code>, I set <code>TargetFramework</code> to <code>netcoreapp2.2</code> because I do not want to use 3.0 just yet.</p>
  
  <p><strong>NOTE 2:</strong> To avoid build errors, I stop Assembly Information generation by adding the following entries under <code>PropertyGroup</code> to both my .csproj files:</p>
  
  <pre><code>&lt;GenerateAssemblyInformationalVersionAttribute&gt;false&lt;/GenerateAssemblyInformationalVersionAttribute&gt;    
  &lt;GenerateAssemblyConfigurationAttribute&gt;false&lt;/GenerateAssemblyConfigurationAttribute&gt;    
  &lt;GenerateAssemblyFileVersionAttribute&gt;false&lt;/GenerateAssemblyFileVersionAttribute&gt;        
  &lt;GenerateAssemblyCompanyAttribute&gt;false&lt;/GenerateAssemblyCompanyAttribute&gt;
  &lt;GenerateAssemblyProductAttribute&gt;false&lt;/GenerateAssemblyProductAttribute&gt;    
  &lt;GenerateAssemblyVersionAttribute&gt;false&lt;/GenerateAssemblyVersionAttribute&gt;
  &lt;GenerateAssemblyTitleAttribute&gt;false&lt;/GenerateAssemblyTitleAttribute&gt;
  </code></pre>
  
  <p><strong>NOTE 3:</strong> Below is my MyProject.csproj file:</p>
  
  <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk"&gt;
  
    &lt;PropertyGroup&gt;
      &lt;OutputType&gt;Exe&lt;/OutputType&gt;
      &lt;TargetFramework&gt;netcoreapp2.2&lt;/TargetFramework&gt;
      &lt;GenerateAssemblyInformationalVersionAttribute&gt;false&lt;/GenerateAssemblyInformationalVersionAttribute&gt;
      &lt;GenerateAssemblyConfigurationAttribute&gt;false&lt;/GenerateAssemblyConfigurationAttribute&gt;
      &lt;GenerateAssemblyFileVersionAttribute&gt;false&lt;/GenerateAssemblyFileVersionAttribute&gt;
      &lt;GenerateAssemblyCompanyAttribute&gt;false&lt;/GenerateAssemblyCompanyAttribute&gt;
      &lt;GenerateAssemblyProductAttribute&gt;false&lt;/GenerateAssemblyProductAttribute&gt;
      &lt;GenerateAssemblyVersionAttribute&gt;false&lt;/GenerateAssemblyVersionAttribute&gt;
      &lt;GenerateAssemblyTitleAttribute&gt;false&lt;/GenerateAssemblyTitleAttribute&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;PackageReference Include="NUnit" Version="*"/&gt;
    &lt;/ItemGroup&gt;
  
  &lt;/Project&gt;
  </code></pre>
  
  <p><strong>NOTE 4:</strong> Below is my Tests.csproj file:</p>
  
  <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk"&gt;
  
    &lt;PropertyGroup&gt;
      &lt;TargetFramework&gt;netcoreapp2.2&lt;/TargetFramework&gt;
      &lt;IsPackable&gt;false&lt;/IsPackable&gt;
      &lt;GenerateAssemblyInformationalVersionAttribute&gt;false&lt;/GenerateAssemblyInformationalVersionAttribute&gt;    
      &lt;GenerateAssemblyConfigurationAttribute&gt;false&lt;/GenerateAssemblyConfigurationAttribute&gt;    
      &lt;GenerateAssemblyFileVersionAttribute&gt;false&lt;/GenerateAssemblyFileVersionAttribute&gt;        
      &lt;GenerateAssemblyCompanyAttribute&gt;false&lt;/GenerateAssemblyCompanyAttribute&gt;
      &lt;GenerateAssemblyProductAttribute&gt;false&lt;/GenerateAssemblyProductAttribute&gt;    
      &lt;GenerateAssemblyVersionAttribute&gt;false&lt;/GenerateAssemblyVersionAttribute&gt;
      &lt;GenerateAssemblyTitleAttribute&gt;false&lt;/GenerateAssemblyTitleAttribute&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;PackageReference Include="nunit" Version="*" /&gt;
      &lt;PackageReference Include="NUnit3TestAdapter" Version="*" /&gt;
      &lt;PackageReference Include="Microsoft.NET.Test.Sdk" Version="*" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;    
      &lt;ProjectReference Include="..\StudentService.csproj" /&gt;
    &lt;/ItemGroup&gt;
  
  &lt;/Project&gt;
  </code></pre>
  
  <p>The warning started showing up once I tried referencing a class inside my <code>Tests</code> project called <code>MyClass</code>. This class is only declared inside my <code>Tests</code> project and does not have any name conflicts with <code>MyProject</code>. I have however read that this might be caused by <code>Tests.csproj</code> referencing <code>MyProject.csproj</code> while being located inside <code>MyProject</code>.</p>
  
  <p>My C# project is structured as follows:</p>
  
  <pre><code>E:\MyCSharpProjects
      MyProject
          MyProject.csproj
          &lt;MyProject code files&gt;
          Tests
              Tests.csproj
              &lt;Tests code files&gt;
  </code></pre>
  
  <p>My questions are:</p>
  
  <ol>
  <li><p>Is having a test project that references my actual project the only way to use NUnit?</p></li>
  <li><p>Is there a way to only have 1 C# project that has NUnit tests inside it, similar to Java and JUnit?</p></li>
  <li><p>I am keeping my test project inside my actual project so they are always together. Is this the standard practice? And if not, what is?</p></li>
  <li><p>How do I get rid of said warning? I'm don't want to ignore it because I don't like having warnings in my code.</p></li>
  </ol>
  
  <p><strong>UPDATE:</strong> In case my questions are too broad to answer, a link on standards on how to write NUnit tests from beginning to end would also be useful.</p>
  
  <hr>
  
  <p><strong>SUMMARY:</strong> <a href="https://stackoverflow.com/users/8959165/desmondgc">desmondgc's</a> answer worked! Turns out all I needed to do was add a <code>.sln</code> file to my project and everything worked perfectly! No warnings, and no need to disable Assembly Information generation at all!</p>
  
  <p>Many thanks to everyone who helped!</p>