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

ILRepack is looking for the "main assembly" in the wrong directory

Open xavierpena opened this issue 6 years ago • 2 comments

Version: 2.0.13

Error message:

>ILRepack: Finished in 00:00:04.7660567
>Done building project "MyProject.csproj".
>(PROJECT-PATH)\MyProject.csproj(39,9): error : ILRepack: The main assembly you specified does not exist: (PROJECT-PATH)\bin\Debug\MyProject.dll.
>Done building project "MyProject.csproj" -- FAILED.	

Indeed (PROJECT-PATH)\bin\Debug\MyProject.dll does not exist, should be (PROJECT-PATH)\bin\Debug\net461\MyProject.dll <= it is missing the $(TargetFramework) part.

Nevertheless, the merged dll seems to be built anyway (also indicated by the message ILRepack: Finished in 00:00:04.7660567).

Task configuration in the .csproj file:

<PropertyGroup>

    <OutputType>library</OutputType>
    <TargetFrameworks>net461</TargetFrameworks>

</PropertyGroup>

<Target Name="ILRepack" AfterTargets="Build">

    <PropertyGroup>
        <WorkingDirectory>$(MSBuildThisFileDirectory)bin\$(Configuration)\$(TargetFramework)</WorkingDirectory>
    </PropertyGroup>

    <ILRepack 
        OutputType="$(OutputType)" 
        MainAssembly="$(AssemblyName).dll" 
        OutputAssembly="$(AssemblyName).dll" 
        InputAssemblies="$(WorkingDirectory)\*.dll" 
		WilcardInputAssemblies="true"
        WorkingDirectory="$(WorkingDirectory)" />

</Target>

xavierpena avatar Mar 14 '19 10:03 xavierpena

I was having this same issue. Turns out that the variable name within the <WorkingDirectory> property should be $(TargetFrameworks) (note the 's' on the end to make 'Framework' plural).

mdavis332 avatar Sep 01 '19 21:09 mdavis332

This drove me nuts for 2 hours, I couldn't figure out why I was getting errors about not finding the main assembly when its completed. Thanks @mdavis332

replaysMike avatar Apr 18 '20 06:04 replaysMike