peters / ILRepack.MSBuild.Task

MSBuild task for ILRepack which is an open-source alternative to ILMerge.
Other
83 stars 31 forks source link

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

Open xavierpena opened 5 years ago

xavierpena commented 5 years ago

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>
mdavis332 commented 5 years ago

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).

replaysMike commented 4 years ago

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