Dotnet core is not supported in xunit.runner.visualstudio version 2.2.0.beta4-build119 #1032

Closed
akazemis opened this Issue Nov 17, 2016 · 18 comments

Comments

Projects
None yet
@akazemis

akazemis commented Nov 17, 2016

Given the following Project.json file (dotnet core project):

{
  "version": "1.0.0-*",
  "testRunner": "xunit",
  "dependencies": {
    "xunit": "2.2.0-beta4-build3444",
    "Moq": "4.6.38-alpha",
    "Ixup.Models": "1.0.0-*",
    "FluentAssertions": "4.15.0",
    "dotnet-test-xunit": "2.2.0-preview2-build1029",
    "xunit.runner.visualstudio": "2.2.0-beta4-build1194"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": "dnxcore50",
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0"
        }
      }
    }
  }
}

I'm getting this error while restoring my NuGet packages :

Errors in E:\Dev\IXUP_App\IxupCore\tests\Ixup.Models.Tests\Ixup.Models.Tests.xproj
Package Microsoft.TestPlatform.ObjectModel 11.0.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.TestPlatform.ObjectModel 11.0.0 supports:
- net35 (.NETFramework,Version=v3.5)
- portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
One or more packages are incompatible with .NETCoreApp,Version=v1.0.

Seemingly this package doesn't support dotnet core, whereas it's explicitly mentioned in the NuGet package description:

Visual Studio 2012+ Test Explorer runner for the xUnit.net framework. Capable of running xUnit.net v1.9.2 and v2.0+ tests.

Supported platforms:
- Desktop .NET 2.0+
- .NET Core (including ASP.NET Core) 1.0+
- Universal Windows App 10+
- Windows App 8.1
- Windows Phone App 8.1

@akazemis akazemis changed the title from Dotnet core is not supported in version 2.2.0.beta4-build119 to Dotnet core is not supported in xunit.runner.visualstudio version 2.2.0.beta4-build119 Nov 17, 2016

@akazemis akazemis closed this Nov 17, 2016

@akazemis akazemis reopened this Nov 17, 2016

@BenjaminAbt

This comment has been minimized.

Show comment
Hide comment
@BenjaminAbt

BenjaminAbt Nov 18, 2016

I get the same error for .NET Core 1.1. My setup:

{
  "version": "1.0.0-*",

  "testRunner": "xunit",

  "dependencies": {
    "NETStandard.Library": "1.6.1",
    "xunit": "2.2.0-beta4-build3444",
    "xunit.runner.visualstudio": "2.2.0-beta4-build1194"
  },

  "frameworks": {
    "netcoreapp1.1": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.1.0"
        }
      }
    }
  }
}

dotnet info:

C:\Users\Ben>dotnet --info
.NET Command Line Tools (1.0.0-preview2-1-003177)

Product Information:
 Version:            1.0.0-preview2-1-003177
 Commit SHA-1 hash:  a2df9c2576

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Visual Studio 2015 Update 3

Aditional info, this setup works for .NET Core 1.1, but my info was, that we should drop dotnet-test-xunit and use xunit.runner.visualstudio instead.

{
  "version": "1.0.0-*",

  "testRunner": "xunit",

  "dependencies": {
    "xunit": "2.2.0-beta4-build3444",
    "dotnet-test-xunit": "2.2.0-preview2-build1029"
  },

  "frameworks": {

   "netcoreapp1.1": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.1.0"
        }
      },
      "imports": [
        "dotnet5.4",
        "portable-net451+win8"
      ]
    }
  }
}


BenjaminAbt commented Nov 18, 2016

I get the same error for .NET Core 1.1. My setup:

{
  "version": "1.0.0-*",

  "testRunner": "xunit",

  "dependencies": {
    "NETStandard.Library": "1.6.1",
    "xunit": "2.2.0-beta4-build3444",
    "xunit.runner.visualstudio": "2.2.0-beta4-build1194"
  },

  "frameworks": {
    "netcoreapp1.1": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.1.0"
        }
      }
    }
  }
}

dotnet info:

C:\Users\Ben>dotnet --info
.NET Command Line Tools (1.0.0-preview2-1-003177)

Product Information:
 Version:            1.0.0-preview2-1-003177
 Commit SHA-1 hash:  a2df9c2576

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Visual Studio 2015 Update 3

Aditional info, this setup works for .NET Core 1.1, but my info was, that we should drop dotnet-test-xunit and use xunit.runner.visualstudio instead.

{
  "version": "1.0.0-*",

  "testRunner": "xunit",

  "dependencies": {
    "xunit": "2.2.0-beta4-build3444",
    "dotnet-test-xunit": "2.2.0-preview2-build1029"
  },

  "frameworks": {

   "netcoreapp1.1": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.1.0"
        }
      },
      "imports": [
        "dotnet5.4",
        "portable-net451+win8"
      ]
    }
  }
}


@charlenni

This comment has been minimized.

Show comment
Hide comment
@charlenni

charlenni Nov 18, 2016

I have the same problems trying to test a portable library, which uses NetStandard 1.6.1. Tried it allready like described on the webpage, but it didn't worked.

I have the same problems trying to test a portable library, which uses NetStandard 1.6.1. Tried it allready like described on the webpage, but it didn't worked.

@codito

This comment has been minimized.

Show comment
Hide comment
@codito

codito Nov 29, 2016

Contributor

The preview2-* version of dotnet-cli toolset supports dotnet-test-xunit, xunit.runner.visualstudio is not compatible.

The newer (preview3-*) version of dotnet-cli toolset supports xunit.runner.visualstudio based test projects. It is not compatible with dotnet-test-xunit. Note that this toolset requires csproj based dotnet projects.

Contributor

codito commented Nov 29, 2016

The preview2-* version of dotnet-cli toolset supports dotnet-test-xunit, xunit.runner.visualstudio is not compatible.

The newer (preview3-*) version of dotnet-cli toolset supports xunit.runner.visualstudio based test projects. It is not compatible with dotnet-test-xunit. Note that this toolset requires csproj based dotnet projects.

@onovotny

This comment has been minimized.

Show comment
Hide comment
@onovotny

onovotny Dec 23, 2016

Member

Closing as @codito's answer is correct.

Member

onovotny commented Dec 23, 2016

Closing as @codito's answer is correct.

@Pastafarian

This comment has been minimized.

Show comment
Hide comment
@Pastafarian

Pastafarian Dec 26, 2016

@onovotny @codito - can you confirm that xunit.net is not compatible with the current version of dotnet core in Visual Studio 2015 and requires 2017 RC1 to work?

@onovotny @codito - can you confirm that xunit.net is not compatible with the current version of dotnet core in Visual Studio 2015 and requires 2017 RC1 to work?

@onovotny

This comment has been minimized.

Show comment
Hide comment
@onovotny

onovotny Dec 27, 2016

Member

xunit does work with VS 2015 and the Preview 2.1 tooling, but you need the right versions. You can see the versions here: http://xunit.github.io/docs/getting-started-dotnet-core.html. For VS 2015/project.json, you'll need to use dotnet-test-xunit.

Member

onovotny commented Dec 27, 2016

xunit does work with VS 2015 and the Preview 2.1 tooling, but you need the right versions. You can see the versions here: http://xunit.github.io/docs/getting-started-dotnet-core.html. For VS 2015/project.json, you'll need to use dotnet-test-xunit.

@thj-dk

This comment has been minimized.

Show comment
Hide comment
@thj-dk

thj-dk Jan 2, 2017

I'm confused by all these versions... Does xUnit work with VS 2017 RC? I've installed xunit.runner.visualstudio v. 2.2.0-beta4-build3444 in my .NET Standard 1.5 class library. The dotnet-cli version is 1.0.0-preview4-004233 (if that has any influence).
But no tests are discovered by VS or ReSharper 2016.3. Any ideas?

thj-dk commented Jan 2, 2017

I'm confused by all these versions... Does xUnit work with VS 2017 RC? I've installed xunit.runner.visualstudio v. 2.2.0-beta4-build3444 in my .NET Standard 1.5 class library. The dotnet-cli version is 1.0.0-preview4-004233 (if that has any influence).
But no tests are discovered by VS or ReSharper 2016.3. Any ideas?

@bradwilson

This comment has been minimized.

Show comment
Hide comment
@bradwilson

bradwilson Jan 2, 2017

Member

@thj-dk wrote:

in my .NET Standard 1.5 class library

The xUnit.net Visual Studio plugin only supports the following platforms:

  • Desktop: net45 and later
  • Windows Phone: wpa81 (being removed in 2.2)
  • Windows Store: win81 (being removed in 2.2)
  • Universal Windows: uwp10.0 and later
  • .NET Core: netcoreapp1.0 and later (starting with 2.2 beta 4)

It does not support PCLs or netstandard DLLs. Why? Because those have no associated platform; they are, by definition, platform agnostic. The Visual Studio plugin needs to know what platform the tests are intended to run on. The solution to your problem is to target one ore more specific platforms.

Member

bradwilson commented Jan 2, 2017

@thj-dk wrote:

in my .NET Standard 1.5 class library

The xUnit.net Visual Studio plugin only supports the following platforms:

  • Desktop: net45 and later
  • Windows Phone: wpa81 (being removed in 2.2)
  • Windows Store: win81 (being removed in 2.2)
  • Universal Windows: uwp10.0 and later
  • .NET Core: netcoreapp1.0 and later (starting with 2.2 beta 4)

It does not support PCLs or netstandard DLLs. Why? Because those have no associated platform; they are, by definition, platform agnostic. The Visual Studio plugin needs to know what platform the tests are intended to run on. The solution to your problem is to target one ore more specific platforms.

@thj-dk

This comment has been minimized.

Show comment
Hide comment
@thj-dk

thj-dk Jan 5, 2017

@bradwilson Thanks alot. That makes sense. So the solution would be to create a net45/netcoreapp1.0 class library to test a netstandard class library, i guess?

thj-dk commented Jan 5, 2017

@bradwilson Thanks alot. That makes sense. So the solution would be to create a net45/netcoreapp1.0 class library to test a netstandard class library, i guess?

@bradwilson

This comment has been minimized.

Show comment
Hide comment
@bradwilson

bradwilson Jan 5, 2017

Member

Yes. Multi-targeting your unit tests for all desired test platforms is what makes sense.

The integration for multi-target projects with the test runner inside Visual Studio is... somewhere between wonky and broken. In the meantime, using separate class library projects with some form of shared source works better.

Member

bradwilson commented Jan 5, 2017

Yes. Multi-targeting your unit tests for all desired test platforms is what makes sense.

The integration for multi-target projects with the test runner inside Visual Studio is... somewhere between wonky and broken. In the meantime, using separate class library projects with some form of shared source works better.

@BalassaMarton

This comment has been minimized.

Show comment
Hide comment
@BalassaMarton

BalassaMarton Mar 14, 2017

xunit.runners.visualstudio also fails to install on Visual Studio 2017 RTM. Steps to reproduce:

  1. Create New Class Library (.NET Core)
  2. Install NuGet package: xunit 2.2.0
  3. Install NuGet package: xunit.runners.visualstudio 2.2.0
    Install fails with the following output:
Package Microsoft.TestPlatform.ObjectModel 11.0.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.TestPlatform.ObjectModel 11.0.0 supports:
  - net35 (.NETFramework,Version=v3.5)
  - portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
One or more packages are incompatible with .NETCoreApp,Version=v1.0.
Package restore failed. Rolling back package changes for 'ClassLibrary1'.

xunit.runners.visualstudio also fails to install on Visual Studio 2017 RTM. Steps to reproduce:

  1. Create New Class Library (.NET Core)
  2. Install NuGet package: xunit 2.2.0
  3. Install NuGet package: xunit.runners.visualstudio 2.2.0
    Install fails with the following output:
Package Microsoft.TestPlatform.ObjectModel 11.0.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.TestPlatform.ObjectModel 11.0.0 supports:
  - net35 (.NETFramework,Version=v3.5)
  - portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
One or more packages are incompatible with .NETCoreApp,Version=v1.0.
Package restore failed. Rolling back package changes for 'ClassLibrary1'.
@BalassaMarton

This comment has been minimized.

Show comment
Hide comment
@BalassaMarton

BalassaMarton Mar 14, 2017

Found the solution here:
https://docs.microsoft.com/en-us/dotnet/articles/core/testing/unit-testing-with-dotnet-test
TL;DR: install the Microsoft.NET.Test.Sdk NuGet first.
My guess is that xunit.runners.visualstudio references a previous version of Microsoft.TestPlatform.ObjectModel that does not target .NET Core. Adding the Microsoft.NET.Test.Sdk
package solves the problem because it references the 15.0.0 version.

Found the solution here:
https://docs.microsoft.com/en-us/dotnet/articles/core/testing/unit-testing-with-dotnet-test
TL;DR: install the Microsoft.NET.Test.Sdk NuGet first.
My guess is that xunit.runners.visualstudio references a previous version of Microsoft.TestPlatform.ObjectModel that does not target .NET Core. Adding the Microsoft.NET.Test.Sdk
package solves the problem because it references the 15.0.0 version.

@epsitec

This comment has been minimized.

Show comment
Hide comment
@epsitec

epsitec Mar 24, 2017

For those who still cannot manage to get xUnit 2.2 and Visual Studio 2017 to work together, you might have some outdated SDK previews getting in the way. My Test Explorer window remained empty, no matter what I did, until I finally uninstalled all x86 SDKs, and removed the the previews found in C:\Program Files\dotnet\sdk to only keep 1.0.0 and 1.0.1.

I blogged about what I did to get things working.

epsitec commented Mar 24, 2017

For those who still cannot manage to get xUnit 2.2 and Visual Studio 2017 to work together, you might have some outdated SDK previews getting in the way. My Test Explorer window remained empty, no matter what I did, until I finally uninstalled all x86 SDKs, and removed the the previews found in C:\Program Files\dotnet\sdk to only keep 1.0.0 and 1.0.1.

I blogged about what I did to get things working.

@raykrow

This comment has been minimized.

Show comment
Hide comment
@raykrow

raykrow Apr 1, 2017

@epsitec's solution worked for me (kindof). I started by only deleting what I had to but it still didn't work. After removing VS2017, VS2015 and ALL dotnet core and only reinstalling VS2017 the problem was solved.

http://stackoverflow.com/questions/42861930/unit-tests-not-discovered-in-visual-studio-2017/43158783#43158783

raykrow commented Apr 1, 2017

@epsitec's solution worked for me (kindof). I started by only deleting what I had to but it still didn't work. After removing VS2017, VS2015 and ALL dotnet core and only reinstalling VS2017 the problem was solved.

http://stackoverflow.com/questions/42861930/unit-tests-not-discovered-in-visual-studio-2017/43158783#43158783

@YLPeng

This comment has been minimized.

Show comment
Hide comment
@YLPeng

YLPeng May 1, 2017

@bradwilson Thanks for the comments. I'm trying to make a .NetStandard library, and according to the comments above, I should create unit tests in a separate project such as .NetCore. My question is can both .NetStandard and .NetCore be in the same solution? Currently I put both in the same solution but it seems I cannot reference .NetStandard library from .NetCore(unit test) class.

YLPeng commented May 1, 2017

@bradwilson Thanks for the comments. I'm trying to make a .NetStandard library, and according to the comments above, I should create unit tests in a separate project such as .NetCore. My question is can both .NetStandard and .NetCore be in the same solution? Currently I put both in the same solution but it seems I cannot reference .NetStandard library from .NetCore(unit test) class.

@bradwilson

This comment has been minimized.

Show comment
Hide comment
@bradwilson

bradwilson May 1, 2017

Member

My question is can both .NetStandard and .NetCore be in the same solution?

Yes.

it seems I cannot reference .NetStandard library from .NetCore(unit test) class.

Can you provide a repro? This should just work. .NET Core < v2.0 can use any version of .NET Standard <= v1.6 (and neither .NET Core 2.0 nor .NET Standard 2.0 are supported by current tooling).

Member

bradwilson commented May 1, 2017

My question is can both .NetStandard and .NetCore be in the same solution?

Yes.

it seems I cannot reference .NetStandard library from .NetCore(unit test) class.

Can you provide a repro? This should just work. .NET Core < v2.0 can use any version of .NET Standard <= v1.6 (and neither .NET Core 2.0 nor .NET Standard 2.0 are supported by current tooling).

@ashokprecise

This comment has been minimized.

Show comment
Hide comment
@ashokprecise

ashokprecise May 2, 2017

Hi,
I am using VisulaStudio2015 Update3 in my .netcore project i have followed all instructions that you provide here. but no luck i cant able to discovered the test result is 0. i don't know what i miss there.

Hi,
I am using VisulaStudio2015 Update3 in my .netcore project i have followed all instructions that you provide here. but no luck i cant able to discovered the test result is 0. i don't know what i miss there.

@YLPeng

This comment has been minimized.

Show comment
Hide comment
@YLPeng

YLPeng May 2, 2017

@bradwilson Thanks so much for getting me back. Yeah it worked, it was a mistake on my part.
@ashokprecise Why not try with VS2017 since it's officially released.

YLPeng commented May 2, 2017

@bradwilson Thanks so much for getting me back. Yeah it worked, it was a mistake on my part.
@ashokprecise Why not try with VS2017 since it's officially released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment