Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to override defaults #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ILRepack.Lib.MSBuild.Task/ILRepack.Lib.MSBuild.Task.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ILRepack.Lib.MSBuild.Task.props">
<SubType>Designer</SubType>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can always delete SubType Designer

<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Copy link
Contributor

@KirillOsenkov KirillOsenkov Dec 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always breaks incrementality, it's better to use PreserveNewest

</None>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
Expand Down
14 changes: 14 additions & 0 deletions ILRepack.Lib.MSBuild.Task/ILRepack.Lib.MSBuild.Task.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ILRepackCustomPropsImport Condition=" '$(ILRepackCustomPropsImport)' == '' ">$(MSBuildProjectDirectory)\ILRepack.Config.props</ILRepackCustomPropsImport>
<ILRepackCustomTargetsImport Condition=" '$(ILRepackCustomTargetsImport)' == '' ">$(MSBuildProjectDirectory)\ILRepack.Config.props</ILRepackCustomTargetsImport>
</PropertyGroup>
<Import Project="$(ILRepackCustomPropsImport)" Condition="Exists('$(ILRepackCustomPropsImport)')" />
<PropertyGroup>
<ILRepackDependsOn Condition=" '$(ILRepackDependsOn)' == '' ">ILRepackGetInputAssemblies</ILRepackDependsOn>
<ILRepackAfterTargets Condition=" '$(ILRepackAfterTargets)' == '' And '$(Configuration)' == 'Release' ">Build</ILRepackAfterTargets>
<ILRepackBeforeTargets Condition=" '$(ILRepackBeforeTargets)' == '' "></ILRepackBeforeTargets>
<CleanReferenceCopyLocalPathsAfterTargets Condition=" '$(CleanReferenceCopyLocalPathsAfterTargets)' == '' And '$(Configuration)' == 'Release' And '$(ClearOutputDirectory)' != 'False' ">ILRepack</CleanReferenceCopyLocalPathsAfterTargets>
</PropertyGroup>
</Project>
29 changes: 20 additions & 9 deletions ILRepack.Lib.MSBuild.Task/ILRepack.Lib.MSBuild.Task.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for an empty PropertyGroup here

</PropertyGroup>
<Import Project="$(ProjectDir)ILRepack.Config.props" Condition="Exists('$(ProjectDir)ILRepack.Config.props')" />
<Choose>
<When Condition="'$(ILRepackTargetsFile)' == ''">
Expand All @@ -10,26 +12,33 @@
</Choose>
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)ILRepack.Lib.MSBuild.Task.dll" TaskName="ILRepack" />
<Import Project="$(ILRepackTargetsFile)" Condition="Exists('$(ILRepackTargetsFile)')" />
<Target Name="ILRepack" AfterTargets="Build" Condition="$(Configuration.Contains('Release')) and !Exists('$(ILRepackTargetsFile)')">
<Target Name="ILRepackGetInputAssemblies">
<ItemGroup>
<InputAssemblies Include="$(OutputPath)$(TargetName)$(TargetExt)"/>
<InputAssemblies Include="$(OutputPath)*.dll" Exclude="$(OutputPath)$(TargetName)$(TargetExt)"/>
</ItemGroup>

<ILRepackInputAssemblies Include="$(OutputPath)$(TargetName)$(TargetExt)"/>
<ILRepackInputAssemblies Include="$(OutputPath)*.dll" Exclude="$(OutputPath)$(TargetName)$(TargetExt)"/>
<ILRepackInputAssemblies Remove="@(ILRepackAssembliesToIgnore)"/>
</ItemGroup>
</Target>
<Target Name="ILRepack" AfterTargets="$(ILRepackAfterTargets)" DependsOnTargets="$(ILRepackDependsOn)" BeforeTargets="$(ILRepackBeforeTargets)" Condition=" !Exists('$(ILRepackTargetsFile)') ">
<PropertyGroup>
<ILRepackOutputAssembly Condition=" '$(ILRepackOutputAssembly)' == '' ">$(OutputPath)$(TargetName)$(TargetExt)</ILRepackOutputAssembly>
</PropertyGroup>
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName($(ILRepackOutputAssembly)))"/>
<ILRepack
Parallel="true"
DebugInfo="true"
AllowDuplicateResources="false"
InputAssemblies="@(InputAssemblies)"
InputAssemblies="@(ILRepackInputAssemblies)"
TargetKind="SameAsPrimaryAssembly"
KeyFile="$(KeyFile)"
OutputFile="$(OutputPath)$(TargetName)$(TargetExt)"
OutputFile="$(ILRepackOutputAssembly)"
LibraryPath="@(ILRepackLibraryPath)"
/>
</Target>
<Target
AfterTargets="ILRepack"
AfterTargets="$(CleanReferenceCopyLocalPathsAfterTargets)"
Name="CleanReferenceCopyLocalPaths"
Condition="$(Configuration.Contains('Release')) and !Exists('$(ILRepackTargetsFile)') and '$(ClearOutputDirectory)' != 'False'">
Condition=" !Exists('$(ILRepackTargetsFile)') ">
<Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
<ItemGroup>
<Directories Include="$([System.IO.Directory]::GetDirectories('$(OutDir)%(DestinationSubDirectory)', '*', System.IO.SearchOption.AllDirectories))" />
Expand All @@ -39,4 +48,6 @@
</ItemGroup>
<RemoveDir Directories="@(Directories)" Condition="%(Files)=='0'" />
</Target>

<Import Project="$(ILRepackCustomTargetImport)" Condition="Exists('$(ILRepackCustomTargetImport)')" />
</Project>