Sunday, October 8, 2017

.Net Core 2 With Tests In Same Project Error CS0017

As I was working on a project that I had migrated to .Net Core 2.0 that used XUnit, I ran into a bit of a dilemma. Upon compiling, I received an odd error: CS0017: 'Program has more than one entry point...' I only had one main method, so I knew this had to be an error and began digging. What I found is that the Microsoft.Net.Test.SDK was actually adding an additional entry point to the compiled output. This can be resolved very simply by updating csproj file's property group with the following:


  <PropertyGroup>  
   <TargetFramework>netcoreapp2.0</TargetFramework>  
   <GenerateProgramFile>false</GenerateProgramFile>  
  </PropertyGroup>  

The solution to this problem was provided by Faizan2304 here:
https://github.com/Microsoft/vstest/issues/636

.Net Core 2 With Tests In Same Project Error CS0017

As I was working on a project that I had migrated to .Net Core 2.0 that used XUnit, I ran into a bit of a dilemma. Upon compiling, I receive...