Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running dotnet test on Mac with net461 #1284

Closed
owenniblock opened this issue Nov 9, 2017 · 12 comments
Closed

Error running dotnet test on Mac with net461 #1284

owenniblock opened this issue Nov 9, 2017 · 12 comments

Comments

@owenniblock
Copy link
Member

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
@smadala
Copy link
Contributor

smadala commented Nov 9, 2017

@owenniblock Please share repro project and diagnostic logs.

@owenniblock
Copy link
Member Author

owenniblock commented Nov 10, 2017

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).

@codito
Copy link
Contributor

codito commented Nov 12, 2017

@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.

@dustinmoris
Copy link

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

@owenniblock
Copy link
Member Author

@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.

@smadala
Copy link
Contributor

smadala commented Dec 4, 2017

@owenniblock This is issue with vstest #1318 (comment).

@pvlakshm
Copy link
Contributor

pvlakshm commented Dec 4, 2017

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

@8bitreid
Copy link

I'm not seeing this as fixed. I'm getting this

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]

@haf
Copy link

haf commented Mar 16, 2018

Ping — will you be fixing this?

@TheAngryByrd
Copy link

+1

@atlemann
Copy link

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.

@smadala smadala self-assigned this Aug 2, 2018
@cltshivash cltshivash self-assigned this Nov 16, 2018
@microsoft microsoft locked as resolved and limited conversation to collaborators Nov 26, 2018
@cltshivash
Copy link
Contributor

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

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

10 participants