-
Notifications
You must be signed in to change notification settings - Fork 105
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
Test discovery fails with exception when test project uses .NET 6+ but references a project using .NET Standard #1213
Comments
Can you please upload a repro project? You can a) Add it as a PR to https://github.com/nunit/nunit3-vs-adapter.issues, add it as a separate folder named IssueXXX where the XXX is the issue number, or b) Add it as a zipped attachment here , or c) Add it to your own repo and just post the link. Make it as small as you can, it should compile "as is". |
@OsirisTerje Pull request is available here. I discovered that in addition to the .NET Standard/.NET 6+ combination, it also depends on having |
The default value of I have been trying this a few times, and if I don't have that attribute set, and clean the solution to get rid of cache issues, then it works. So it seems I can't repro this. |
I don't think it needs to be set explicitly to |
@CharliePoole The engine is handling this. I would assume it needs that attribute. Is that correct? @dselzle Did this work earlier with any other combination of .net frameworks? |
Yes, it's how it determines the target framework. If I remember correctly, it assumes .NET Framework 2.0 if the attribute is not found. If the adapter has better information, e.g. from the project file, you could add a setting to the test package to request the use of a certain framework. |
With the class library targeting Standard 2.0, I tried Framework 4.6, 4.6.2, 4.8, and 4.8.1 (all working), and .NET 6, 7, and 8 (all failing) for the test project. |
@dselzle Can you explain some use cases where you wouldn't want to have a |
@CharliePoole A few years ago, we had some builds start failing due to "duplicate" TargetFrameworkAttributes for reasons we could never figure out. We started setting that attribute to false by default for all of our projects and haven't had any more issues. Like I said, the workaround for this test discovery issue is simple enough in this case. |
OK, in that case, I guess I ought to simply document the fact that you can defeat discovery using this setting. |
I set up a barebones solution with two projects. One was a class library targeting .NET Standard 2.0, and the other was a unit test project targeting .NET 8.0. The test project included a reference to the class library project (
<ProjectReference Include="..\path\to\ClassLibrary.csproj" />
).Versions:
Test discovery fails with the following logs:
If I change the test project to target .NET Framework 4.6.2+, or if I change the class library to .NET 6+, test discovery works fine. The exception is only thrown when the library project is .NET Standard and the test project is .NET 6+.
I tried deleting bin/ and obj/ folders and restarting Visual Studio, but the behavior didn't change.
The text was updated successfully, but these errors were encountered: