-
Notifications
You must be signed in to change notification settings - Fork 255
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 Failures due to auto redirection for nuget packages in VS #6723
Comments
Any update on this ? This is currently causing one of the top issues users of the test framework are running into. |
@cltshivash Does this work before? Which VS version it works on? We haven't changed code related to this for a long time. I suspect something changed in VS. |
@zhili1208 : I will need to check this. The issue repros on the latest 15.6 update. Do you need the exact VS version where it worked ? |
@zhili1208 : The issue repros on VS 2015 as well. You will need to set the target framework for the classlibrary and the test project as 4.6.2. It doesn't repro if this is set as 4.6.1 or 4.7.*. Hope this helps in narrowing down the cause. |
@zhili1208 : Any update on this issue ? |
@cltshivash we are trying to work on this bug this sprint. |
That's great, thanks for the update @cltshivash! |
@cltshivash Thanks for reporting the issue. I am currently investigating this issue. Will it be possible for you to unblock yourself by moving the class library to package reference style instead of packages.config? |
FWIW, this has been happening to my team intermittently over the last year, mostly without including moq. Just using the two MSTest nuget packages that the 4.6.2 (and 4.5.2) unit test project template installs and adding a single unit test to that project and VS will fail to discover that test. We unblock by removing those two packages entirely and then reffing the old MS quality framework dll. This lets local and server builds always find all the tests and execute them. Changing anything to package reference will not be an option. |
Hi @StingyJack 😊
Wonder why? That's is the new way and where we're all headed... |
Hey @spottedmahn - I did the math once for someone on the nuget team who asked the same question . For all the projects and solutions my team has to maintain, it came out to over 4 weeks of time to migrate from package.config to the packageref and that's with only a minimal (smoke) test. I cant make any business argument that justifies spending that kind of time when the potential value add is so trivial. I actually have several other reasons but dont want to side track getting this very nasty defect fixed. For > 6 months unit tests were failing silently and new bugs were getting into code that was delivered to customers. |
Interesting, thanks for sharing! @StingyJack |
@cltshivash I investigated a bit. Here is a rundown -
Update - I have created an issue to track the issue about removing binding redirects on uninstall - #6870. |
@mishra14 : Could you please clarify on point 4 which project's bin directory ? Below is the content of the testproject's output directory which has no System.RunTime.dll present but the config file (UnitTestProject1.dll.config has the below redirection). Now execution is going to fail as the redirected version will not be found. |
@mishra14 The test execution uses the testproject's output location as the appbase for an appdomain and tries to invoke the test method. If there's a config file for the test dll , it is added to the appdomain setup info. |
@cltshivash Thanks for giving me more information. In my last pass I was installing Moq on the main project and hence missed the issue. I investigated this from the test project's point of view. The root cause here is that in Please keep in mind that even if the binding redirect was not added, you still needed a reference to This specific problem is fixed by design in |
Visual Studio has forever been "helping" me by finding whatever reference or dependency a project needed by looking in all kinds of places. While sometimes this caused frustrating "works on my machine" issues, it was probably overall a good thing. So a project that has references has references that know their references. and so on (for static refs ). Was there a reason why the original design of nuget did not just take advantage of this? |
@mishra14 Migating the nuget references off package.config to PackageReference helps resolve the issue for the repro shared on this issue (i do see the runtime dll getting copied to the output folder of the test project). @StingyJack Please do see if the option provided by @mishra14 helps. |
@spottedmahn It would be helpful if you can validate the above recommendation from @mishra14 |
@cltshivash thanks for confirming. I am closing this issue. |
So if I read this correctly the problem that I originally was discussing - where unit tests fail to be discovered due to an assembly reference issue, and do so silently - is not going to be fixed thanks to some (fairly deft) interdepartmental juggling. |
@StingyJack NuGet has been moving towards If you want to keep using |
I wasn't blocked. Once i realized that half the unit tests were not being executed for gated checkin builds, working around it was done in short order. But its every single test project that gets created that I have to either fix or show someone how to fix, or we are at risk of unintentionally delivering broken code to a customer. You are leaving me with two choices really; use a package management system that is going to cost me a lot of time, that is buggy, and that has less features, or continue the manual hack I have now in perpetuity, So I can use MSTest and have it discover and run all the tests that are actually present. Doesnt seem right... |
Details about Problem
NuGet product used : VS 15.6.2 update
VS version (if appropriate):
OS version (i.e. win10 v1607 (14393.321)): N/A
Detailed repro steps so we can see the same problem
Users authoring test projects are running into issues with with the auto redirection being added without the right assemblies being present in the output location. More details below.
Repro (https://github.com/smadala/samples/tree/master/Test%20Explorer%20fails%20to%20show%20tests/ClassLibrary.Tests)
https://github.com/spottedmahn/Experiments/tree/master/Test%20Explorer%20fails%20to%20show%20tests
Detailed Repro Steps
This is affecting a lot of users (as seen in microsoft/testfx#241). If this isn't the right place to track this issue, do let me know.
The text was updated successfully, but these errors were encountered: