Closed jnm2 closed 4 years ago
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?
I wish I knew. Would it be possible for you to cc your colleagues for a recommendation?
@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.
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.
What are the features ILMerge provides compared to Mono ILLinker?
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.
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.
@mike-barnett I am asking since the tools are similar and I don't think we need both.
@erozenfeld I'm aware of the difference in implementation (Cecil vs CCI). That's kind of my point. Cecil supports Portable PDBs already.
@tmat There are plans to support assembly merging in ILLink but it's not clear how soon that will happen. /cc @russellhadley @swaroop-sridhar
@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.
@mike-barnett No worries. I just wanted to point out that rather then investing into ILMerge we could spend time on making ILLink better.
So in the meantime...
In the meantime you can perhaps use Pdb2Pdb: https://github.com/dotnet/symreader-converter. Package: https://dotnet.myget.org/feed/symreader-converter/package/nuget/Pdb2Pdb
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 https://github.com/gluck/il-repack/issues/182, https://github.com/gluck/il-repack/issues/230, https://github.com/gluck/il-repack/pull/236)
@poizan42 I've tested ILRepack from the master branch but the same exception happens.
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
.
@walterlv I think we are still waiting for https://github.com/gluck/il-repack/pull/236 to be merged
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
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
The build is succeeding in Visual Studio now
If Portable PDBs are not required then you can select the 'Full' option for 'Debugging information:'
Steps
Compile your project and it will work.
If you don't need debug symbols in your merged output, you can also use /ndebug
rather than changing what is generated.
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.
Any update on this? Or is there a workaround on how to debug merged assemblies?
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?
@mike-barnett Thanks for the answer. Appreciate the work you've put on on ILMerge!
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
as demonstrated by this simple test: https://github.com/Microsoft/ILMerge/compare/master...jnm2:portable_pdb_bug
This is somewhat of a integral issue. Where should this capability be on the roadmap?