C#C
C#3y ago
LukeJ

✅ Can no longer run console app after adding unit tests

I made a little test project that I've slowly been building onto. It's gotten big enough now that I've added NUnit unit tests to make it easier, but I seem to have done it wrong and now the app won't open. When I hit run it brings up a configuration window with the error on the bottom Error: Project has no runnable target frameworks defined. The Target framework parameter shows net6.0 though, so I'm not sure what the problem is.

Here's what the csproj file looks like
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="LanguageExt.Core" Version="4.4.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0-preview-20221221-03" />
    <PackageReference Include="NUnit" Version="3.13.3" />
    <PackageReference Include="NUnit.Console" Version="3.16.2" />
  </ItemGroup>

</Project>

I added in the Microsoft.NET.Test.Sdk to get the unit tests to appear in the test runner, but it also causes this error running it normally. Comparing it to a freshly made unit test project, the csproj looks about the same. I've definitely done something wrong in adding the nunit packages, but I have no idea what.
Was this page helpful?