Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Support for portable PDBs #11

Closed
jnm2 opened this issue May 4, 2017 · 24 comments
Closed

Support for portable PDBs #11

jnm2 opened this issue May 4, 2017 · 24 comments

Comments

@jnm2
Copy link
Contributor

jnm2 commented May 4, 2017

With the new csproj format, the default is the superior portable PDB format for all .NET projects, including traditional .NET Framework apps.

ILMerge will crash with

An exception occurred during merging:
ILMerge.Merge:        There were errors reported in ReferencedProject's metadata.
      Array dimensions exceeded supported range.
   at ILMerging.ILMerge.Merge()
   at ILMerging.ILMerge.Main(String[] args)

as demonstrated by this simple test:
master...jnm2:portable_pdb_bug

This is somewhat of a integral issue. Where should this capability be on the roadmap?

@mike-barnett
Copy link
Contributor

Hmm, I'm guessing that a different PDB reader would have to be used instead of the one that ILMerge/CCI currently uses, which is some COM object of type CorSymBinder2. Would you know if the new reader can handle both the portable PDB format and the old format? I.e., can we just switch to the new one and use that alone?

@jnm2
Copy link
Contributor Author

jnm2 commented May 5, 2017

I wish I knew. Would it be possible for you to cc your colleagues for a recommendation?

@pharring
Copy link

pharring commented May 5, 2017

@tmat for comment. I don't think there's a "universal" reader. You'd have two code-paths. However, there are tools that can convert between the formats so, in theory, one could build a universal reader.

@mike-barnett
Copy link
Contributor

I'll also take a look at how CCI2 handles this. As a more general comment, I believe the direction ILMerge should take is to remove its dependence on the System.Compiler project (which is CCI1) and instead get rewritten against CCI2. Or we just move. I've already created an initial version . But it doesn't have any of the many options that this version has.

@tmat
Copy link
Member

tmat commented May 5, 2017

What are the features ILMerge provides compared to Mono ILLinker?

@mike-barnett
Copy link
Contributor

I don't know. I'd love it if there were a better tool so we could put ILMerge down for good. But I've had at least one person say they had tried some other Mono utility (could be that one) and that they preferred to stay with ILMerge. No accounting for taste... Why do you ask? Do you think ILLinker is as good or better than ILMerge? It looks from a cursory glance that they also do tree shaking, which is a nice thing.

@erozenfeld
Copy link
Member

ILLink does tree shaking but doesn't merge assemblies (yet) so the two tools do different things at the moment. Another difference is that ILLink uses Cecil, while ILMerge uses CCI for reading and writing assemblies.

@tmat
Copy link
Member

tmat commented May 5, 2017

@mike-barnett I am asking since the tools are similar and I don't think we need both.

@tmat
Copy link
Member

tmat commented May 5, 2017

@erozenfeld I'm aware of the difference in implementation (Cecil vs CCI). That's kind of my point. Cecil supports Portable PDBs already.

@erozenfeld
Copy link
Member

@tmat There are plans to support assembly merging in ILLink but it's not clear how soon that will happen.
/cc @russellhadley @swaroop-sridhar

@mike-barnett
Copy link
Contributor

@tmat Totally agree! Hope my question did not sound confrontational! Getting the merging to work in ILLink sounds like a great thing, but I'm afraid I don't have the time to commit to doing that. But if there are people there that are working on it, then I will definitely drop the idea of moving ILMerge onto CCI2.

@tmat
Copy link
Member

tmat commented May 5, 2017

@mike-barnett No worries. I just wanted to point out that rather then investing into ILMerge we could spend time on making ILLink better.

@jnm2
Copy link
Contributor Author

jnm2 commented May 6, 2017

So in the meantime...

@tmat
Copy link
Member

tmat commented May 6, 2017

@poizan42
Copy link

poizan42 commented Sep 4, 2018

I'm surprised no one has mentioned this - an alternative to ILMerge is ILRepack. Once it has been migrated to use Mono.Cecil 0.10 it should work with portable pdbs (see gluck/il-repack#182, gluck/il-repack#230, gluck/il-repack#236)

@walterlv
Copy link

@poizan42 I've tested ILRepack from the master branch but the same exception happens.

image

The ILRepack has a 0.10 branch but the critical commits have never been merged to the master. So the main tool still does not support the portable pdbs. But if I checkout to the 0.10 branch, I get another exception of type InvalidOperationException.

@poizan42
Copy link

@walterlv I think we are still waiting for gluck/il-repack#236 to be merged

@cathalnoonan
Copy link

Hi guys, I think I found a workaround for this

Try to delete (or rename) the .pdb file in the packages folder of your project

image

After doing this, I had a problem where it couldn't merge "System.Threading.Tasks.Extensions".
The error message was "Unresolved assembly reference not allowed"

After some trial and error, I copied the contents of the following directory into the Scriban package directory
\packages\System.Threading.Tasks.Extensions.4.5.3\lib\portable-net45+win8+wp8+wpa81

image

The build is succeeding in Visual Studio now

@sohailrazarizvi
Copy link

If Portable PDBs are not required then you can select the 'Full' option for 'Debugging information:'

Steps

  • RIght-Click Project in Visual Studio
  • Click Build on left hand menu
  • Click 'Advanced...' button from the bottom of the page. This will open 'Advanced Build Settings' dialog
  • From 'Output' section; select 'Full' option for 'Debugging information:'

Compile your project and it will work.

image

@BobVul
Copy link

BobVul commented Sep 18, 2019

If you don't need debug symbols in your merged output, you can also use /ndebug rather than changing what is generated.

@mygithub07
Copy link

mygithub07 commented Jan 30, 2020

I was getting similar error while using MSBuild.ILMerge.Task and I tried workaround by cathalnoonan above . That error is gone , but now I get same error for a different package. And I already have "Full" selected as mentioned by sohailrazarizvi above . What is the general solution/workaround for this , so I don't get this error for any package? The error is :

Error       ILMerge.Merge:  There were errors reported in TechTalk.SpecFlow's metadata.
    Exception of type 'System.OutOfMemoryException' was thrown. 

@MaxXor
Copy link

MaxXor commented May 30, 2020

Any update on this? Or is there a workaround on how to debug merged assemblies?

@mike-barnett
Copy link
Contributor

At this point, ILMerge will never be able to read portable PDBs. It would require moving ILMerge to work on top of CCI2, which I just don't see happening. I don't know what has happened in the meantime with the ILLink project that is mentioned above in this thread. Maybe that is now able to merge assemblies?

@jnm2
Copy link
Contributor Author

jnm2 commented Jun 28, 2020

@mike-barnett Thanks for the answer. Appreciate the work you've put on on ILMerge!

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

No branches or pull requests