ILRepack.MSBuild.Task icon indicating copy to clipboard operation
ILRepack.MSBuild.Task copied to clipboard

Operation is not valid due to the current state of the object.

Open icnocop opened this issue 10 years ago • 13 comments

I'm getting the following error when trying to merge assemblies:

Merging 32 assembies to 'c:\work\dev\test1\project1\bin\Debug\\project1.dll'. (TaskId:102)
c:\work\dev\test1\project1.csproj(547,6): error : Operation is not valid due to the current state of the object.

But there's no other helpful information associated with the error. There's no log file (ex. %temp%\MSBuild_*.failure.txt)

Any ideas?

I expected a more specific error that indicates which assembly failed to be merged so that I can possibly exclude it from being internalized.

  <!-- ILRepack -->
  <Target Name="AfterBuild">

     <ItemGroup>
      <InputAssemblies Include="$(OutputPath)\*.dll" />
     </ItemGroup>

     <ILRepack 
      Parallel="true"
      Internalize="true"
      InputAssemblies="@(InputAssemblies)"
      TargetKind="Dll"
      ZeroPeKind="true"
      Verbose="true"
      OutputFile="$(OutputPath)\$(AssemblyName).dll" />

  </Target>
  <!-- /ILRepack -->

Thank you.

icnocop avatar Jan 21 '16 20:01 icnocop

For my specific case, I had to set Internalize="false" but I still don't understand why.

icnocop avatar Jan 27 '16 03:01 icnocop

I hit this issue as well. If you don't wildcard the InputAssemblies it also works

codinghipster avatar Mar 03 '16 14:03 codinghipster

In my case this occurs when trying to include EntityFramework dll's

Jogai avatar Mar 12 '16 11:03 Jogai

Any update on this issue. Cause I am hitting the same error on dapper.extensions

qamaruddin avatar Apr 20 '16 11:04 qamaruddin

Also getting this, but none of the previous suggestions worked for me. I removed ILRepack.

CodyBatt avatar Sep 07 '16 16:09 CodyBatt

Same. I'm going to have to punt ILRepack.

JoeHz avatar May 19 '17 04:05 JoeHz

Same. Works for my DLLs, fails once I include EntityFramework 6.0.0 regardless of internallize true/false, wildcard, etc.

lsamaha avatar Aug 25 '17 14:08 lsamaha

'+ 1. Same error and no ideas why

FixRM avatar Sep 22 '17 11:09 FixRM

Faced this issue today. Removed this packages and added ILRepack.2.0.15 nuget package which has ILRepack.exe and used exec "exec" task in csproj to the the job. No more such issue!

vijaygill avatar Mar 24 '18 20:03 vijaygill

Can confirm that ditching this project and invoking ILRepack.exe explicitly works fine.

Is this project even being maintained?

nullpainter avatar Oct 14 '18 20:10 nullpainter

@nullpainter I can recommend this one https://github.com/ravibpatel/ILRepack.Lib.MSBuild.Task

FixRM avatar Oct 15 '18 08:10 FixRM

I can recommend this one https://github.com/ravibpatel/ILRepack.Lib.MSBuild.Task

@FixRM that works beautifully. Thank you!

nullpainter avatar Oct 19 '18 04:10 nullpainter

Closing this issue. I've made significant changes to the build task in order to support netstandard2.0 and netcoreapp. Please do check it out.

peters avatar Jan 12 '19 04:01 peters