-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
BadImageFormatException: Microsoft.Build.Tasks.CodeAnalysis #10
Comments
Can you please try commenting out this line: Also, would you mind providing the top of the stack trace so that I can see which specific line or method it's failing on. Thanks! |
Stack Trace:
Not commenting the line: 12 tests fail. (BadImageFormatException) |
If I run the tests from the command line ( |
Now that you mention it, I actually hit this earlier myself. Should have remembered. I usually use the Resharper test runner which is x64 by default, but briefly switched to the VS one and had similar problems. I resolved it by going to Test -> Test Settings -> Default Processor Architecture -> x64. Does that resolve it for you as well? |
All the tests are passing now, but I still can't understand why it doesn't work in my application. The dotnet host is x64, so it should work. |
Is the host application platform target explicitly x64 or just AnyCPU? Not that it should make any difference since AnyCPU is supposed to pick the x64 runtime when it's available, but maybe worth checking. |
The target is AnyCPU, and I only have the .NET Core CLI x64 version installed. |
Now I'm getting this exception: https://pastebin.com/VnuwCQKn |
Oh, wow, you broke it good 😄. On the one hand I think this is good because it means that you're actually getting past the previous problems and we're calling the MSBuild API successfully. On the other hand, this looks like it'll be nasty to track down since it's deep in the MSBuild libraries (looks like the method that kicks off the problem is Is the project you're trying to analyze open source and available somewhere I could get it to try and reproduce? |
Also, what platform are you running on? |
I was getting the same thing: (the stack trace is exactly the same as provided by @jp2masa). In my case, I was attempting to use Buildalyzer from a .NET 4.7 console application. Based on the above discussions, I checked the compiler settings and found this: Unchecking that check box gets me past this error. |
@kentcb Thanks - I think I know how to get around this. MSBuild ships both x64 and x32 binaries by default, but I'm pretty sure Buildalyer is defaulting to the x64 path. I'll take a look at how to switch to the x32 libraries if the host application is detected as a x32 process. |
It's looking more and more like a x86 .NET Framework application building a .NET Core SDK-style project via the MSBuild APIs isn't a supported scenario by MSBuild and the project system. The I'll update the table in the readme to make this clear and leave the issue a little while longer until I'm certain, but otherwise there isn't much we can do about x86 .NET Framework hosts using the SDK. |
The x86 version of the .NET Core SDK probably ships a x86 version of |
@jp2masa That's an excellent point! I forgot that there was a totally separate x86 SDK distribution. Going to try installing it to see what the path difference is (and what |
@jp2masa That did the trick - just needed to add a check and manually change the path we look at (since |
I was trying to use Buildalyzer to load .NET Core SDK project, but I was getting this exception:
I thought that probably I was making some mistake, but then I downloaded this repo and tried to run the tests. The .NET Core and .NET Standard SDK project tests fail with the same exception.
Buidalyzer version: 0.1.4
Visual Studio version: 15.4
dotnet --info:
The text was updated successfully, but these errors were encountered: