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

The predefined type 'System.Runtime.CompilerServices.ExtensionAttribute' is defined in multiple assemblies in the global alias #194

Closed
NecroFilja opened this issue Jul 1, 2016 · 16 comments

Comments

@NecroFilja
Copy link

After adding NUnit3TestAdapter to project (nuget) with tests stops building:

The predefined type 'System.Runtime.CompilerServices.ExtensionAttribute' is defined in
multiple assemblies in the global alias; using definition from 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\mscorlib.dll' C:\Projects\WebProject\WebProject.Tests\error CS1685 WebProject.Tests

@CharliePoole
Copy link
Contributor

What references to test adapter classes exist in your project after adding the package?

@NecroFilja
Copy link
Author

Hello,

I just minimized number of refereferences and it still fails. We have quite agressive error treatment - all warnings are considered as errors (due of management requirements). May be this is due of this fact.
I attached whole project, for me references looks like standard.
WebProject.Tests.zip

@CharliePoole
Copy link
Contributor

Your project contains a bunch of MS test references as well as NUnit references. Why is that? Are you trying to use both kinds of tests in the same assembly?

@NecroFilja
Copy link
Author

Generally we are migrating from MSTest to NUnit. So some artifacts could remain.
But not sure they affect logic. The only way it works for me - removing all this Mono., nunit. staff.
Leaving only NUnit3.TestAdapter reference. Strange but look like it works without all this.

@CharliePoole
Copy link
Contributor

Can we close this or is there still an issue?

@NecroFilja
Copy link
Author

Still have error.

@CharliePoole
Copy link
Contributor

So,if you still have the error after removing the extraneous references, does it indicate to you which assemblies provide duplicate definitions or is only one assembly listed in the message?

@fredericDelaporte
Copy link

fredericDelaporte commented Aug 24, 2016

Got same issue.
As a workaround, I have changed in the test project on the nunit.engine reference the Aliases property to nunit instead of global. (Found by fiddling with all references.)
So the offending nunit reference looks to be this nunit.engine assembly.

The test project targets .Net fx 4.5.2.
NUnit3TestAdapter v3.4.1 has been added with NuGet.

@CharliePoole
Copy link
Contributor

Are you saying your test project has a reference to nunit.engine? If so did you add it or did the nuget install do so? The adapter has a reference to the engine, but your project should have no need of it.

@fredericDelaporte
Copy link

Yes, the test project does have a direct reference to nunit.engine.
I can not say precisely how it was added, the colleague having set up the test project is currently on holidays. I had supposed it was added by NuGet, but well, maybe not.
Since it looks like it should not be there, I will try wiping the project NuGet and nunit references and set them again tomorrow (I am no more at work currently). I will report the result here.

@fredericDelaporte
Copy link

fredericDelaporte commented Aug 25, 2016

I confirm that adding the NuGet <package id="NUnit3TestAdapter" version="3.4.1" targetFramework="net452" /> add this nunit.engine dependency to the test project, along with a bunch of other dependencies (nunit.engine.api, Mono.Cecil, Mono.Cecil.Mdb, Mono.Cecil.Pdb, Mono.Cecil.Rocks; and of course NUnit3.TestAdapter).

@maikhanns
Copy link

I had the same problem on my tfs build machine. There was a warning because of the nunit.engine reference. After removing the reference the warning is gone. I think the reference was set by nuget install.

@ChrisMaddock
Copy link
Member

ChrisMaddock commented Oct 18, 2016

I believe the nuspec should be specifying the intended project references with <references>, or else everything in the /lib/ dir will be added as a project reference.

I don't use the adapter. I assume it's just the NUnit3.TestAdapter.dll that should be referenced by a test project?

Edit: Ah, just found the related #221. That would be another solution!

@CharliePoole
Copy link
Contributor

The adapter is a tool and shouldn't be referenced at all. However, it was originally created using the lib directory because some old version of VS needed it to be there. We have an issue to fix this for 3.5.

@OsirisTerje
Copy link
Member

@CharliePoole Afaic see, this is fixed. The adapter is no longer added as reference to the project, so we should have no such issues. Suggest we can close this.

@CharliePoole
Copy link
Contributor

I agree.

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

No branches or pull requests

6 participants