Skip to content
This repository has been archived by the owner on Nov 27, 2017. It is now read-only.

Support .NET Core 2.0 #122

Closed
vasily-kirichenko opened this issue Sep 10, 2017 · 4 comments
Closed

Support .NET Core 2.0 #122

vasily-kirichenko opened this issue Sep 10, 2017 · 4 comments

Comments

@vasily-kirichenko
Copy link

Trying to run tests with dotnet test fails:

Test run for E:\github\ExtCore\ExtCore.Tests\bin\Debug\netstandard2.0\ExtCore.Tests.dll(.NETStandard,Version=v
2.0)                                                                                                          
Microsoft (R) Test Execution Command Line Tool Version 15.3.0-preview-20170628-02                             
Copyright (c) Microsoft Corporation.  All rights reserved.                                                    
                                                                                                              
Starting test execution, please wait...                                                                       
No test is available in E:\github\ExtCore\ExtCore.Tests\bin\Debug\netstandard2.0\ExtCore.Tests.dll. Make sure test project has a nuget reference of package "Microsoft.NET.Test.Sdk" and framework version settings are appropriate and try again.                                                                                        
                                                                                                              
Test run for E:\github\ExtCore\ExtCore.Tests\bin\Debug\net45\ExtCore.Tests.dll(.NETFramework,Version=v4.5)    
Microsoft (R) Test Execution Command Line Tool Version 15.3.0-preview-20170628-02                             
Copyright (c) Microsoft Corporation.  All rights reserved.                                                    
                                                                                                              
Starting test execution, please wait...                                                                       
NUnit Adapter 3.8.0.0: Test execution started                                                                 
Running all tests in E:\github\ExtCore\ExtCore.Tests\bin\Debug\net45\ExtCore.Tests.dll                        
Exception System.InvalidOperationException, Exception thrown executing tests in E:\github\ExtCore\ExtCore.Tests\bin\Debug\net45\ExtCore.Tests.dll                                                                           
Operation is not valid due to the current state of the object.                                                
NUnit Adapter 3.8.0.0: Test execution complete                                                                
No test is available in E:\github\ExtCore\ExtCore.Tests\bin\Debug\net45\ExtCore.Tests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.                                                                                                             

The project looks like this:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="TestHelpers.fs" />
    <Compile Include="RefCountEnumerable.fs" />
     <!-- many more files here -->
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\ExtCore\ExtCore.fsproj" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="FsCheck" Version="2.10.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
    <PackageReference Include="NUnit" Version="3.8.1" />
    <PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
  </ItemGroup>
</Project>

Do I understand correctly that .NET Standard/Core 2 is not supported?

@rprouse
Copy link
Member

rprouse commented Sep 14, 2017

.NET Standard/Core is supported. The problem is that your tests target .NET Standard 2.0, they need to target .NET Core 2.0. Unit tests must target a specific platform, they cannot target netstandard. This is by design by Microsoft and is the same for all test frameworks.

See https://github.com/nunit/docs/wiki/.NET-Core-and-.NET-Standard for more info.

@vasily-kirichenko
Copy link
Author

Thanks, it works now :)

@rprouse
Copy link
Member

rprouse commented Sep 14, 2017

Good to know, thanks for reporting back.

@equiman
Copy link

equiman commented Oct 3, 2017

I'm only change <TargetFramework>netstandard2.0</TargetFramework> to <TargetFramework>netcoreapp2.0</TargetFramework> on .csproj file and works again.

Thanks! @rprouse

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants