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

Problem of AutoFixture current version with Moq current version #260

Closed
binydev opened this issue Mar 8, 2014 · 15 comments
Closed

Problem of AutoFixture current version with Moq current version #260

binydev opened this issue Mar 8, 2014 · 15 comments
Labels

Comments

@binydev
Copy link

binydev commented Mar 8, 2014

when i build my application using Team Foundation MsBuild I face this problem. it work on my local computer I face this problem when it is on server.

System.IO.FileLoadException: Could not load file or assembly 'Moq, Version=3.1.416.3, Culture=neutral, PublicKeyToken=69f491c39445e920' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Ploeh.AutoFixture.AutoMoq.MockPostprocessor.Create(Object request, ISpecimenContext context)

@moodmosaic
Copy link
Member

Could you try to add binding redirects to the config file via NuGet (or manually)?

@binydev
Copy link
Author

binydev commented Mar 10, 2014

Ya I know.. on my local computer build it works... but on deployment it doesnt!

@ploeh
Copy link
Member

ploeh commented Mar 10, 2014

Are you using the same test runner on your local computer and the build server, or is it two different test runners?

@ploeh ploeh added the question label Mar 10, 2014
@binydev
Copy link
Author

binydev commented Mar 10, 2014

I use the same. I use visual studio 2012 on my local computer and TFS 2012 on server. we configure automated build and deployment on test server. and when I trigger build it show me the following error.

Test method NeoplexERP.Service.Business.UnitTests.Core.LookupBusinessService_GetAllTest.Should_GetAll_Gender threw exception:
System.IO.FileLoadException: Could not load file or assembly 'Moq, Version=3.1.416.3, Culture=neutral, PublicKeyToken=69f491c39445e920' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Ploeh.AutoFixture.AutoMoq.MockPostprocessor.Create(Object request, ISpecimenContext context)

@ploeh
Copy link
Member

ploeh commented Mar 10, 2014

I don't know how TFS works, but from the exception message, it's quite clear that it can't find Moq, so either it's not picking up the assembly redirect, or the file is not available on the server.

If you can provide a way to reproduce the issue (without asking us to install TFS), we can take a look, but otherwise, this sounds like a TFS issue rather than an AutoFixture issue.

@binydev
Copy link
Author

binydev commented Mar 10, 2014

No no... it is not related to TFS issue! there is Moq.dll on build folder but it is version 4.0... in my local computer the same I have only version 4.0... but it show me this error message when it is on build server! why is that...?

@moodmosaic
Copy link
Member

How TFS invokes MSBuild? What are the arguments supplied to the MSBuild.exe process?

@binydev
Copy link
Author

binydev commented Mar 10, 2014

we give arguments on build definition! and MSBuild.exe will be called with those configuration

@adamchester
Copy link
Member

Can you post the full build log somewhere? (Not here, just give us the URL).

@ploeh
Copy link
Member

ploeh commented Mar 10, 2014

There's not a lot of detail to go with here.

It may be true that the issue isn't related to TFS, but if that's the case, you should be able to tell us how to reproduce the issue.

Right now, based on my experience, the error message you're seeing is always caused by a problem with assembly redirects. Either the assembly redirect is incorrect, or the test runner isn't picking it up. Keep in mind that having an app.config file associated with a library (.dll) isn't picked up the .NET run-time by default, so it's something every test runner explicitly does.

@binydev
Copy link
Author

binydev commented Mar 10, 2014

@ploeh I agree with your approach... due to the TFS build copy only one version of Moq (4....) unable to redirect to the exact version. my point is I remove version Moq(3.6...) on my local computer and I run the test project it work fine... why no it does not work on other machine? "Ploeh.AutoFixture.AutoMoq.MockPostprocessor.Create" does not request version 3.6... why it use version 4?

@ploeh
Copy link
Member

ploeh commented Mar 30, 2014

@bcopmt143 Were you able to resolve your issue?

@ploeh
Copy link
Member

ploeh commented Apr 3, 2014

Closing due to inactivity.

@ploeh ploeh closed this as completed Apr 3, 2014
@Skm5900
Copy link

Skm5900 commented Dec 6, 2022

Hi Team,
Same issue facing here, unit test having reference to AutoFixture is not working for below line of code on devOps pipeLine build, on local it works fine. Please sugggest.

@aivascu
Copy link
Member

aivascu commented Dec 8, 2022

@Skm5900 It might be that you are relying on the implicit version of Moq added by AutoFixture.AutoMoq.
The Moq version in our packages is intentionally kept at lower values to enable more compatibility.
You should install Moqpackage in your test projects and update it to the latest version.

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

No branches or pull requests

6 participants