Closed biz0n closed 6 years ago
Current workaround: put this line after nuget reference
<Target AfterTargets="AfterBuild" Name="CleanReferenceCopyLocalPaths" />
It would be better if you rename AfterBuild
target in ILRepack.Lib.MSBuild.Task.targets
If I replace the current targets file with file discussed in this comment then users can provide their own targets file for ILRepack.
This solution doesn't work for me. In our project we use one target for two projects and I can't put ILRepack.targets near project file.
@biz0n Is there any reason to not put the targets near project file?
yes, because we use one target for two project
Sample structure of our projects: ../GooglePlay/GooglePlay.csproj ../Amazon/Amazon.csproj ../AndroidShared/ILRepack.targets
@biz0n What if I provide configuration file where you can define where your targets file resides. You just need to add configuration file in each project and it will use it.
You can check property. Something like Condition="'$(IgnoreDefaultILRepackBehavior)' == 'true'"
@biz0n Already created targets file for that. Here it is.
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(ProjectDir)ILRepack.Config.props" Condition="Exists('$(ProjectDir)ILRepack.Config.props')" />
<Choose>
<When Condition="'$(ILRepackTargetsFile)' == ''">
<PropertyGroup>
<ILRepackTargetsFile>$(ProjectDir)ILRepack.targets</ILRepackTargetsFile>
</PropertyGroup>
</When>
</Choose>
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)ILRepack.Lib.MSBuild.Task.dll" TaskName="ILRepack" />
<Import Project="$(ILRepackTargetsFile)" Condition="'$(Configuration)' == 'Release' and Exists('$(ILRepackTargetsFile)')" />
<Target Name="ILRepack" AfterTargets="Build" Condition="'$(Configuration)' == 'Release' and !Exists('$(ILRepackTargetsFile)')">
<ItemGroup>
<InputAssemblies Include="$(OutputPath)$(TargetName)$(TargetExt)"/>
<InputAssemblies Include="$(OutputPath)*.dll" Exclude="$(OutputPath)$(TargetName)$(TargetExt)"/>
</ItemGroup>
<ILRepack
Parallel="true"
DebugInfo="true"
AllowDuplicateResources="false"
InputAssemblies="@(InputAssemblies)"
TargetKind="SameAsPrimaryAssembly"
KeyFile="$(KeyFile)"
OutputFile="$(OutputPath)$(TargetName)$(TargetExt)"
/>
</Target>
<Target
AfterTargets="ILRepack"
Name="CleanReferenceCopyLocalPaths"
Condition="'$(Configuration)' == 'Release' and !Exists('$(ILRepackTargetsFile)') and '$(ClearOutputDirectory)' != 'False'">
<Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
<ItemGroup>
<Directories Include="$([System.IO.Directory]::GetDirectories('$(OutDir)%(DestinationSubDirectory)', '*', System.IO.SearchOption.AllDirectories))" />
<Directories>
<Files>$([System.IO.Directory]::GetFiles("%(Directories.Identity)", "*", System.IO.SearchOption.AllDirectories).get_Length())</Files>
</Directories>
</ItemGroup>
<RemoveDir Directories="@(Directories)" Condition="%(Files)=='0'" />
</Target>
</Project>
You just need to add ILRepack.Config.props file in your project folder with following contents.
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ILRepackTargetsFile>$([System.IO.Path]::GetDirectoryName($(MSBuildProjectDirectory)))\ILRepack.targets</ILRepackTargetsFile>
</PropertyGroup>
</Project>
Hello! We have a problem with using your ILRepack MSBuild task Nuget attaches to csproj files
ILRepack.Lib.MSBuild.Task.targets
that merge all *.dll from project folder After merge it removes all dll files If you want to merge only few files you should override "AfterBuild" and "CleanReferenceCopyLocalPaths" targets.