ILMerge-MSBuild-Task icon indicating copy to clipboard operation
ILMerge-MSBuild-Task copied to clipboard

Exception of type 'System.OutOfMemoryException' was thrown.

Open aalmada opened this issue 6 years ago • 6 comments

I'm using VS 2019, with .NET Core SDK 3.1.100-preview3 installed and a csproj file with the following:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
  <PropertyGroup>
    <TargetFrameworks>net472</TargetFrameworks>
    <OutputType>exe</OutputType>
    <UseWindowsForms>true</UseWindowsForms>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="ilmerge" Version="3.0.29" />
    <PackageReference Include="ILMerge.MSBuild.Task" Version="1.0.7" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Bonsai.Configuration\Bonsai.Configuration.csproj" />
    <ProjectReference Include="..\Bonsai.Design\Bonsai.Design.csproj" />
    <ProjectReference Include="..\Bonsai.Editor\Bonsai.Editor.csproj" />
    <ProjectReference Include="..\Bonsai.NuGet\Bonsai.NuGet.csproj" />
  </ItemGroup>
</Project>

The ILMergeConfig.json file constains the following:

{
  "General": {
    "InputAssemblies": [
      "NuGet.Core.dll",
      "Bonsai.NuGet.dll",
      "Bonsai.Configuration.dll"
    ]
  },
  "Advanced": {
    "ExcludeFile": "ilmerge.internalize.exclude.txt",
    "Internalize": true
  }
}

I get the following log:

6>C:\Users\antao\.nuget\packages\ilmerge.msbuild.task\1.0.7\build\ILMerge.MSBuild.Task.targets(13,5): error : ILMerge.Merge: 	There were errors reported in Bonsai's metadata.
6>C:\Users\antao\.nuget\packages\ilmerge.msbuild.task\1.0.7\build\ILMerge.MSBuild.Task.targets(13,5): error : 	Exception of type 'System.OutOfMemoryException' was thrown.

Removing the Advanced section results in the same error.

The project can be found at https://bitbucket.org/aalmada/bonsai/src/netcoreapp3.0/Bonsai/

aalmada avatar Nov 19 '19 10:11 aalmada

Trying to use it with the .Net 4.7.2 application and also get the OutOfMemory exception: image

My config is super simple:

{
  "General": {
    "InputAssemblies": [
      "IdentityModel.dll"
    ]
  }
}

nZeus avatar Apr 08 '20 19:04 nZeus

It happens during the first compilation, when the output folder is empty. When I build my project for the second time - this exception doesn't occur anymore. But it seems the assembly didn't get merged

nZeus avatar Apr 08 '20 20:04 nZeus

@nZeus I switched to ILRepack with ILRepack.MSBuild.Task.

https://github.com/aalmada/bonsai/blob/d396a981cbee3cfdf34197f8b3b0aafaa6b29f8b/Bonsai/Bonsai.csproj#L144

aalmada avatar Apr 13 '20 08:04 aalmada

I did the same :)

nZeus avatar Apr 13 '20 08:04 nZeus

FYI The issue is the DebugType which defaults to portable for new SDK-style projects. Setting

<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>

Fixes it for me

pinkfloydx33 avatar May 06 '20 11:05 pinkfloydx33

Same errore here. I have a 4.5.2 project that works but on 4.7.2 it crashes, event with my project setted with DebugSymbols and DebugType as said @pinkfloydx33

feminho avatar May 14 '20 16:05 feminho