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

New-style projects targetting full framework produces broken PDB and breaks VS tooling #1816

Closed
poke opened this issue Mar 8, 2017 · 2 comments
Labels

Comments

@poke
Copy link

poke commented Mar 8, 2017

Hey, I found a problem when using the new concise project format targetting the full framework. For this, assume the following project file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>
</Project>

Next to the project file is a simple static class that doesn’t really do anything. Just as a demo.

This project compiles fine from dotnet CLI (1.0.0) using dotnet build, MSBuild (v15), and also from within Visual Studio 2017. However, the generated PDB for the library weighs just 1KB and appears to be broken. When I try to open the DLL with ILSpy, I get an OutOfMemoryException when it tries to load the PDB. After removing the PDB from the file system, I can open the DLL just fine with ILSpy, so the library compilation itself appears to work just fine. But the PDB is broken.


The other issue I see, which might be related to the broken PDB, is with the Visual Studio tooling when attempting to consume the above library. I have an example ASP.NET Core project (targetting the full framework) that references above library. When I attempt to use the types defined in the library, Visual Studio reports an error that the library “does not exist in the current context”.

However, actually compiling and running the web application does work just fine. The types can be used properly and the code in the library is also executed properly. The compilation will also not fail in Visual Studio although the error message remains in the error list (suggesting that the compilation has failed when it hasn’t).

Compiling and/or running the web application from the command line does not show the error. So it’s just the Visual Studio tooling that’s not working here. This might be related to the library’s PDB being broken, if that’s how Visual Studio sets up IntelliSense for project references.

@poke
Copy link
Author

poke commented Mar 8, 2017

While attempting to reproduce this inside a minimal test project on a different machine, I found two new behaviors within Visual Studio: In some cases, everything works fine, correctly highlighting the library namespace and giving me IntelliSense for it. In other cases, the exact same code (just used elsewhere) will not get any tooling support (no syntax highlighting, no IntelliSense) but will also not produce any error.

In all cases, I however cannot navigate to the type using F12, likely due to the PDB being broken.

Anyway, I set up a test project here: https://github.com/poke/msbuild-issue1816 – Unfortunately, this is only giving me broken tooling without the appearing error in the error list at the moment. I’ll try to figure out what’s causing that exactly.

@poke
Copy link
Author

poke commented Mar 8, 2017

Together with help from @dasMulli on chat, we figured out that the PDB appears to be correct after all. Apparently, portable PDBs are created by default and those seem to be incompatible with ILSpy. Related bugs already exists over there for the exact error I encountered (icsharpcode/ILSpy#723 and icsharpcode/ILSpy#779).

That left the Visual Studio tooling broken though. But after moving the example code around from one machine to another, less and less problems appeared to stick around until they suddenly all disappeared. Might be related to restarting Visual Studio in the end.

So this issue solved itself over time. Nothing to see here… *sigh*

@poke poke closed this as completed Mar 8, 2017
@AR-May AR-May added the triaged label Feb 21, 2024
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

2 participants