Giter Club home page Giter Club logo

Comments (8)

biz0n avatar biz0n commented on June 14, 2024

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

from ilrepack.lib.msbuild.task.

ravibpatel avatar ravibpatel commented on June 14, 2024

If I replace the current targets file with file discussed in this comment then users can provide their own targets file for ILRepack.

from ilrepack.lib.msbuild.task.

biz0n avatar biz0n commented on June 14, 2024

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.

from ilrepack.lib.msbuild.task.

ravibpatel avatar ravibpatel commented on June 14, 2024

@biz0n Is there any reason to not put the targets near project file?

from ilrepack.lib.msbuild.task.

biz0n avatar biz0n commented on June 14, 2024

yes, because we use one target for two project

Sample structure of our projects:
../GooglePlay/GooglePlay.csproj
../Amazon/Amazon.csproj
../AndroidShared/ILRepack.targets

from ilrepack.lib.msbuild.task.

ravibpatel avatar ravibpatel commented on June 14, 2024

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

from ilrepack.lib.msbuild.task.

biz0n avatar biz0n commented on June 14, 2024

You can check property. Something like Condition="'$(IgnoreDefaultILRepackBehavior)' == 'true'"

from ilrepack.lib.msbuild.task.

ravibpatel avatar ravibpatel commented on June 14, 2024

@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>

from ilrepack.lib.msbuild.task.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.