Vstest: Error running dotnet test on Mac with net461

Created on 9 Nov 2017  Â·  12Comments  Â·  Source: microsoft/vstest

Description

When I test a .Net 4.6.1 test class - the test fails to run and exits with an error.

Steps to reproduce

  1. Create a Test class using .Net 4.6.1
  2. Specify the mono framework location: export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.6.1-api
  3. Run dotnet test -f net461

Expected behavior

The tests load and run in the terminal.

Actual behavior

Test fails with error:

Failed to initialize client proxy: could not connect to test process.

Diagnostic logs

Error in the log file:

TpTrace Error: 0 : 58259, 6, 2017/11/07, 14:26:42.303, 603606289580000, vstest.console.dll, Test host exited with error: ''

Environment

.NET Command Line Tools (2.0.2)

Product Information:
 Version:            2.0.2
 Commit SHA-1 hash:  a04b4bf512

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.0.2/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d
bug dotnet-cli

All 12 comments

@owenniblock Please share repro project and diagnostic logs.

I've created the repo here

The log is in the repo

Interestingly - dotnet won't build this project (it builds within VS 4 Mac fine) but when I run
dotnet test -f net461 --no-build -d log.txt

I get the error:

MyTestClass.cs(7,6): error CS0012: The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. [/Users/owenniblock/Projects/ExampleTest/ExampleTest/ExampleTest.csproj]
MyTestClass.cs(10,10): error CS0012: The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. [/Users/owenniblock/Projects/ExampleTest/ExampleTest/ExampleTest.csproj]

If I run the following command: dotnet test -f net461 --no-build -d log.txt after running FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.6.1-api it exhibits the behaviour reported in the Issue.

(The original project which led me to report the error builds successfully but I can't share that unfortunately).

@owenniblock I think mono requires all references to be explicitly mentioned in csproj (observed this while fixing few build issues on Linux for vstest repo). The test project is old project system based. dotnet build/test may not work with it.

I'd suggest moving the project to new project system and adding System.Runtime reference for getting dotnet build to work. Here's an example of adding conditional dependency for net46. A sample project with new project system can be generated with dotnet new mstest.

I have the same issue, did you find out what you had to reference for it to work?

@dustinmoris - No, I'm afraid not. I think we've decided to go down the dotnet core route for the project we were on. I got this issue when investigating alternatives to dotnet core so didn't have enough time to dig in to it any deeper.

@owenniblock This is issue with vstest https://github.com/Microsoft/vstest/issues/1318#issuecomment-348735719.

This ought to be fixed - it should check for Mono and work as appropriate.

I'm not seeing this as fixed. I'm getting this
```someUsers-mbp:MySecondTest someUsersComp$ dotnet new mstest -n MyTest
The template "Unit Test Project" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on MyTest/MyTest.csproj...
Restoring packages for /Users/someUsersComp/Developer/vsCode/msTest/MySecondTest/MyTest/MyTest.csproj...
/usr/local/share/dotnet/sdk/2.0.0/NuGet.targets(102,5): error : Access to the path '/Users/someUsersComp/.nuget/packages/microsoft.dotnet.platformabstractions/1.0.3/lib/net451' is denied. [/Users/someUsersComp/Developer/vsCode/msTest/MySecondTest/MyTest/MyTest.csproj]
/usr/local/share/dotnet/sdk/2.0.0/NuGet.targets(102,5): error : Permission denied [/Users/someUsersComp/Developer/vsCode/msTest/MySecondTest/MyTest/MyTest.csproj]

Ping — will you be fixing this?

+1

I got dotnet test working for a net461 test project on Ubuntu. Created a small repo here. It's a workaround at least. For more info about it, look here.

Please follow the workaround provided by @atlemann for this issue.

Was this page helpful?
0 / 5 - 0 ratings