emerbrito / ILMerge-MSBuild-Task

Adds ILMerge to Visual Studio 2013/2017 or automated builds. This Task is intended to work right out of the box however, it supports a configuration file where you can control every ILMerge property including the list of assemblies to be merged.
MIT License
54 stars 15 forks source link

Exception of type 'System.OutOfMemoryException' was thrown. #34

Open aalmada opened 4 years ago

aalmada commented 4 years ago

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/

nZeus commented 4 years ago

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 commented 4 years ago

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

aalmada commented 4 years ago

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

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

nZeus commented 4 years ago

I did the same :)

pinkfloydx33 commented 4 years ago

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

feminho commented 4 years ago

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