-
Notifications
You must be signed in to change notification settings - Fork 258
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
FileNotFoundException for Microsoft.Testing.Platform.dll using EnableMSTestRunner with netstandard2.0 #3984
Comments
@jeremy-visionaid I confirm the behavior and I was going to close as by-design because I thought console app weren't supporting netstandard2.0 but it appears it does so this seems to be a bug on our side. Out of curiosity, may I ask what's your "goal" in testing as netstandard? I have never seen such kind of test. |
@Evangelink are you sure? Net standard isn't a runtime, it's more like an interface that both net framework and net core implement. So it shouldn't be possible to test or run a console app because you wouldn't have an actual runtime. So by design actually makes sense. I made a basic console app and switched the target framework to netstandard2.0 and it indeed doesn't run (as expected.) |
Ha, of course you're both right. I'm somewhat surprised at the actual behaviour there given that it shouldn't be runnable. The background is that I was making some contributions to an upstream library, and was tired and copied the TFMs from a library to a test project to ensure it was being tested for all the combinations of dependencies that were being built (There were inconsistent TFMs for the projects across the wider solution, so it was non-trivial to reason which TFMs would be resolved for the dependencies). I was thinking that it would have been nice to just set the same ones for the test project, but didn't quite think through the consequences. Whether it's reasonable/valid or not, libraries/NuGets could do something like I have changes lined up for the upstream to target more modern TFMs and make them consistent, so the underlying reason for doing it won't exist for very long, but the behaviour for MSTest was nonetheless curious/surprising. Whether anything should be done about it is another matter! |
That's what I thought! Interestingly, |
I don't know actually, with a breakpoint and process explorer we can check, I suppose it's using a dotnet muxer and passing the target dll like |
It works because the dll you are producing is internally an executable (it has entrypoint and everything), and cmd uses CreateProcessW to run it. It does not care about the extension, but most likely checks the "magic" header in the file, I cannot find evidence for this, and I am not so willing to look at the source code of cmd if I could even find it :D but if you rename the file to Once the process is started, .NET Framework CLR is bootstrapped by windows (because it knows about .NET Framework apps), and the execution is then handed over to .NET Framework, and the program runs as normal. (We are using absolutely the same in our integration testst in testfx, where we produce DLLs, not exe for .NET framework targets, and we hand them over to cmd to execute them.) In VS it is the same, there the debug host is also calling cmd. |
For .NET technically it can also work, the netstandard2.0 built dll is not internally special, but netstandard does not produce runtimeconfg.json during build, because it is not meant to run.
But if you produce one, e.g. by building net9.0 TFM and taking that, or by simply writing it, to tell the app which runtime it should choose, the netstandard2.0 dll will run as well via dotnet.
We use this in testhost in vstest to be able to run as the desired TFM, and as fallback for newer TFMs, but we do not use it to run netstandard2.0 apps, and I don't think we should start doing that. |
Describe the bug
Microsoft.Testing.Platform.dll, etc. are not being copied to the output directory via _CopyFilesMarkedCopyLocal when targeting netstandard2.0
Steps To Reproduce
Add multi-targeting to a test project like so:
Expected behavior
Tests can be run via Test Explorer and/or running the test binary
Actual behavior
Additional context
It appears to work OK for net6.0 and net8.0...
The text was updated successfully, but these errors were encountered: