Giter Club home page Giter Club logo

ilrepack.lib.msbuild.task's People

Contributors

aldomat avatar alexx999 avatar aminya avatar aviadmini avatar ermshiperete avatar fixrm avatar jairbubbles avatar kirillosenkov avatar michel-pi avatar pinkfloydx33 avatar ravibpatel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ilrepack.lib.msbuild.task's Issues

Force exclude a library reference from being merged in

I'm trying to merge a library X that references an optional library Y (it can run without it, any potential exceptions are ignored). However, ILRepack goes out of its way to merge all references, including the optional ones that I removed from my project, which results in "Failed to resolve assembly: Y". I tried adding <InputAssemblies Exclude="Y"/> but the error still occurs.

The only solution I can think of is to make a copy of X that doesn't reference Y at all, but then I would have to update two copies of X in parallel.

How can I force exclude a library reference so ILRepack won't try to merge it?

ILRepack.Config.props gets ignored.

The documentation (which is very sparse btw) says, put the config in the project.
But the file gets ignored if I build the whole solution.

InvalidCastException when trying to merge Oracle.ManagedDataAccess.dll

1> System.InvalidCastException: No se puede convertir un objeto de tipo 'System.SByte' al tipo 'System.String'.
1> en Mono.Cecil.MetadataBuilder.GetConstantSignature(ElementType type, Object value)
1> en Mono.Cecil.MetadataBuilder.AddConstant(IConstantProvider owner, TypeReference type)
1> en Mono.Cecil.MetadataBuilder.AddField(FieldDefinition field)
1> en Mono.Cecil.MetadataBuilder.AddFields(TypeDefinition type)
1> en Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
1> en Mono.Cecil.MetadataBuilder.AddTypeDefs()
1> en Mono.Cecil.MetadataBuilder.BuildTypes()
1> en Mono.Cecil.MetadataBuilder.BuildModule()
1> en Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)
1> en Mono.Cecil.ModuleWriter.WriteModuleTo(ModuleDefinition module, Stream stream, WriterParameters parameters)
1> en Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
1> en ILRepacking.ILRepack.Repack()
1> en ILRepacking.Application.Main(String[] args)
This works fine if we use the Oracle.ManagedDataAccess.dll v 19.18.0. All versions after that one returns System.InvalidCastException.

Any idea how to fix it?

InternalizeExclude implemented incorrectly

Internalize Exclude expects a file that has a list (one per line) of Regular expressions. These patterns are used to match namespaces/classes in the combined assemblies which should not be internalized.

At the moment, ILRepack.cs attempts to correlate the InternalizeExcludes with the Assemblies. The assembly information should have nothing to do with these. For example, I may be packing 3 DLLs but I may be excluding 10 different regex/namespaces. At the moment, the loop over InternalizeExclude attempts to access the array of assemblies using the same index. This will crash the build if we're on exclude number 4 with 3 assemblies.

if (!File.Exists(assemblies[i]) && !File.Exists(BuildPath(assemblies[i])))

That if statement (line 311-314) should be removed. The Log message at line 315 should be updated to indicate that "pattern ^XYZ$ is being excluded.". The exception message at 309 should probably be updated to say something like: "Invalid Exclude Pattern at Index {i}; Pattern cannot be blank"

CleanReferenceCopyLocalPaths Not Happening v2.0.18.1

I'm not able to get the CleanReferenceCopyLocalPaths Target to happen. I've enabled verbose logging, and don't see anything related to it.

I've setup both a ILRepack.Config.props file and an ILRepack.targets file within my Project.

Here is my targets file:

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="AfterBuild">
    <ItemGroup>
      <InputAssemblies Include="$(OutputPath)\$(AssemblyName).dll" />
      <InputAssemblies Include="$(OutputPath)\de\*.dll" />
      <InputAssemblies Include="$(OutputPath)\es\*.dll" />
      <InputAssemblies Include="$(OutputPath)\en\*.dll" />
      <InputAssemblies Include="$(OutputPath)\fr\*.dll" />
      <InputAssemblies Include="$(OutputPath)\it\*.dll" />
      <InputAssemblies Include="$(OutputPath)\ja\*.dll" />
      <InputAssemblies Include="$(OutputPath)\ko\*.dll" />
      <InputAssemblies Include="$(OutputPath)\pt-pt\*.dll" />
      <InputAssemblies Include="$(OutputPath)\zh-cn\*.dll" />
      <InputAssemblies Include="$(OutputPath)\zh-tw\*.dll" />
    </ItemGroup>
    <ILRepack Parallel="true" Verbose="true" LogFile="c:\temp\output.txt" InputAssemblies="@(InputAssemblies)" LibraryPath="$(OutputPath)" KeyFile="$(AssemblyOriginatorKeyFile)" OutputFile="$(OutputPath)\$(AssemblyName).dll" />
  </Target>
</Project>

And here is my props file:

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <ILRepackTargetsFile>$(ProjectDir)ILRepack.targets</ILRepackTargetsFile>
    <ClearOutputDirectory>True</ClearOutputDirectory>
  </PropertyGroup>
</Project>

image
I'm hoping it would delete all of the satelite assemblies in the language subfolders shown above. But they appear to still all be there.

image

It merges all of the correct DLLs but does not cleanup the source .dlls. Could anyone help me?

ILRepack is not working for desktop framework

I have several entry points, one of them is .Net Framework 4.8 console application. Libraries are standard 2.0
ILRepack here is not working after installation. If I manually include ILRepack.target to the project iports, it executes but produces bad file. Exe is no longer executable, it throws 'Access Denied' and 'Can't run on your pc'. (of course app is working before ILRepack)

Release configuration merge gives error failed to resolve assembly

Hello @ravibpatel

I have created a new C# project and used ILRepack.Lib.MSBuild.Task.2.0.18.1 and added below code in my project .csproj file and it works absolutely fine, but when I add earlybound class file ([assembly: Microsoft.Xrm.Sdk.Client.ProxyTypesAssemblyAttribute()]) to my project It gives below error.

What do you think could be the problem? Can you please share the solution of the problem?

<Import Project="..\packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets" Condition="Exists('..\packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets')" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> </PropertyGroup> <Error Condition="!Exists('..\packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets'))" /> </Target>

1> D365.Plugins -> C:\Users\admin\source\repos\D365.Plugins\D365.Plugins\bin\Release\D365.Plugins.dll
1> Added assembly 'bin\Release\Microsoft.Crm.Sdk.Proxy.dll'
1> Added assembly 'bin\Release\microsoft.identitymodel.dll'
1> Added assembly 'bin\Release\Microsoft.ServiceBus.dll'
1> Added assembly 'bin\Release\Microsoft.Xrm.Client.CodeGeneration.dll'
1> Added assembly 'bin\Release\Microsoft.Xrm.Client.dll'
1> Added assembly 'bin\Release\Microsoft.Xrm.Portal.dll'
1> Added assembly 'bin\Release\Microsoft.Xrm.Portal.Files.dll'
1> Added assembly 'bin\Release\Microsoft.Xrm.Sdk.Deployment.dll'
1> Added assembly 'bin\Release\Microsoft.Xrm.Sdk.dll'
1> Merging 9 assembies to 'bin\Release\D365.Plugins.dll'
1>C:\Users\admin\source\repos\D365.Plugins\packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets(19,5): error : Failed to resolve assembly: 'Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

PrimaryAssemblyFile only added on Release Builds

The PrimaryAssemblyFile seems to be added only on Release Builds via a relative path. ..\..\[...]\UIControls.dll

Debug Log

INFO: IL Repack - Version 2.0.18
VERBOSE: Runtime: ILRepack.Lib.MSBuild.Task, Version=2.0.18.2, Culture=neutral, PublicKeyToken=f7072046361f3979
INFO: ------------- IL Repack Arguments -------------
/out:D:\[...]\merged\UIControls.dll  D:\[...]UIControls.dll D:\[...]\de\UIControls.resources.dll
-----------------------------------------------
INFO: Adding assembly for merge: D:\[...]\UIControls.dll
INFO: Adding assembly for merge: D:\[...]\UIControls.resources.dll

Release Log

INFO: IL Repack - Version 2.0.18
VERBOSE: Runtime: ILRepack.Lib.MSBuild.Task, Version=2.0.18.2, Culture=neutral, PublicKeyToken=f7072046361f3979
INFO: ------------- IL Repack Arguments -------------
/out:D:\[...]\merged\UIControls.dll ..\..\[...]\UIControls.dll  D:\[...]UIControls.dll D:\[...]\de\UIControls.resources.dll
-----------------------------------------------
INFO: Adding assembly for merge: ..\..\[...]\UIControls.dll
INFO: Adding assembly for merge: D:\[...]\UIControls.dll
INFO: Adding assembly for merge: D:\[...]\de\UIControls.resources.dll
[...]
ERROR: Duplicate type UIControls.ControlA

The target is identical for both configurations. When I remove the first InputAssembly it's content is missing on Debug builds.

*csproj

<Target Name="ILRepacker" AfterTargets="Build">
    <ItemGroup>
		<InputAssemblies Include="$(TargetDir)$(AssemblyName).dll" />
		<InputAssemblies Include="$(TargetDir)de\$(AssemblyName).resources.dll" />
    </ItemGroup>
    <ILRepack Parallel="true" DebugInfo="true" InputAssemblies="@(InputAssemblies)" TargetKind="SameAsPrimaryAssembly" OutputFile="$(TargetDir)\merged\$(AssemblyName).dll" Verbose="true" LogFile="$(TargetDir)log.txt" />
  </Target>

Support regex in InternalizeExclude

It appears that ILRepack offers support for using regular expressions within the /internalize option, as indicated in the official documentation. However it seems that the project is using an older version of ILRepack which lacks this capability.

Would you be able to assist in updating the project to a version of ILRepack that supports the use of regular expressions in the InternalizeExclude parameter?

Build task isn't re-signing/strong-naming my assembly

Which file do you specifically place the <KeyFile>$(ProjectDir)key.snk</KeyFile> element when you need to sign/strong name the resultant merged assembly?

I've copied the contents of this file into my project:
https://github.com/ravibpatel/ILRepack.Lib.MSBuild.Task/blob/caf641eab2567434562e37768aba04559e6e0b24/ILRepack.Lib.MSBuild.Task/ILRepack.Config.props

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <KeyFile>$(ProjectDir)key.snk</KeyFile>
  </PropertyGroup>
</Project>

And the SNK file exists (key.snk) under the $(ProjectDir). But my output DLL is still not being signed; when I check the key with the sn.exe tool, it says:

Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Failed to convert key to token -- Invalid assembly public k

Is it in the csproj file, the ILRepack.Config.props or the ILRepack.targets file?

I've also tried adding it to the ILRepack.targets file, then I get an error:
14/10/2022 12:13:07 PM Critical Project load failed| [MSB4067] The element <#text> beneath element <KeyFile> is unrecognized. C:\Users\mmiftah\source\repos\solution\project\ILRepack.targets at (18:3)
I've also tried adding it to the CSPROJ file, but the build output still doesn't change.

Problem with TargetPlatformVersion parameter

I have to set very specific target platform version to avoid reference hell in product environment. I can archive this by passing /targetplatform:v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319 parameter via command line.

Unfortunately if I set TargetPlatformVersion="v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319" in config I get "Failed to find target platform 'v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319' in 'C:\Windows\Microsoft.NET\Framework"

p.s. Folder exist.

An option to exclude some asseblies

Hi. I'm getting the error "Failed to resolve assembly" during merge. The problem is that I don't need this assembly to be merged as it will be available in target environment.

ILRepack.Lib.MSBuild.Task does not work on Linux

Hello,
I would like to use ILRepack MSBuild Task on Linux, but having a dependency on Microsoft.Build.Utilities.v4.0 make it impossible to use it.

error MSB4062: The "ILRepack" task could not be loaded from the assembly /root/.nuget/packages/ilrepack.lib.msbuild.task/2.0.16/build/ILRepack.Lib.MSBuild.Task.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

There is a plan to make this NuGet package Linux compatible?

Thank you,
Marc-André

dotnet build not working

if using dotnet build instead of msbuild there is an error that Microsoft.Build.Utilities.v4.0 cannot be found!

The "ILRepack" task could not be loaded from the assembly ....nuget\packages\ilrepack.lib.msbuild.task\2.0.18\build\ILRepack.Lib.MSBuild.Task.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

Update to ILRepack 2.0.31

I am not sure of your update cadence, but i just got a fix merged into ILRepack 2.0.31, and would really like that fix reflected here as i like using your MSBuild task.

Problem with duplicate Types

When using the TaskScheduler package (https://github.com/dahall/taskscheduler) in a project and using ILRepack to merge all assemblies, I get the following error:

error : Duplicate type System.Collections.Generic.EventedList`1 from GroupControls.dll, was also present in AeroWizard, Version=2.2.3.0, Culture=neutral, PublicKeyToken=915e74f5d64b8f37

Obviously, the same type is present in two repedent packages. How can I configure ILRepack to handle this problem?

Release configuration merges more assemblies when needed

Hello @ravibpatel,

I have the following configuration and it works great for Debug builds:

<Target Name="AfterBuild">
   <ItemGroup>
     <InputAssemblies Include="$(OutputPath)\$(AssemblyName).dll" />
     <InputAssemblies Include="$(OutputPath)\D365Extensions.dll" />
     <InputAssemblies Include="$(OutputPath)\Newtonsoft.Json.dll" />
   </ItemGroup>
   <ILRepack Parallel="true" DebugInfo="true" InputAssemblies="@(InputAssemblies)" KeyFile="$(AssemblyOriginatorKeyFile)" LibraryPath="$(OutputPath)" OutputFile="$(OutputPath)\$(AssemblyName).dll" />
 </Target>

as you can see, there is no conditions or something. For some reasons I see the following output for Release build:
1> SomePlugin -> C:...\bin\Release\SomePlugin.dll
1> Added assembly 'bin\Release\SomePlugin .dll'
1> Added assembly 'bin\Release\D365Extensions.dll'
1> Added assembly 'bin\Release\Newtonsoft.Json.dll'
1> Merging 3 assembies to 'bin\Release\SomePlugin.dll'
1> Merge succeeded in 0,8986863 s
1> Added assembly 'bin\Release\SomePlugin.dll'
1> Added assembly 'bin\Release\D365Extensions.dll'
1> Added assembly 'bin\Release\Newtonsoft.Json.dll'
1> Added assembly 'bin\Release\SomePlugin .dll'
1> Added assembly 'bin\Release\D365Extensions.dll'
1> Added assembly 'bin\Release\Microsoft.Crm.Sdk.Proxy.dll'
1> Added assembly 'bin\Release\Microsoft.Xrm.Sdk.dll'
1> Added assembly 'bin\Release\Microsoft.Xrm.Sdk.Workflow.dll'
1> Added assembly 'bin\Release\Newtonsoft.Json.dll'
1> Merging 9 assembies to 'bin\Release\SomePlugin.dll'
1>C:...\packages\ILRepack.Lib.MSBuild.Task.2.0.16.1\build\ILRepack.Lib.MSBuild.Task.targets(19,5): error : Failed to resolve assembly: 'Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Both Debug and Release configurations are not customized. Any ideas?

Target ILRepack.Lib.MSBuild.Task.targets remove all files

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.

Repacking Harmony in Debug mode fails

Hi,

my open source project Harmony uses this task to pack its "Fat" releases. It works fine but we discovered that the "DebugFat" release does not work on .NET 5 or newer. Packing itself isn't the problem because ReleaseFat works just fine.

The problem is very easy to replicate by cloning the project (master) and running tests for DebugFat and ReleaseFat.

There is an active discussion going on on my discord server where the guys from the MonoMod.Core project (a dependency Harmony has) discuss that this is related to them using some function pointer here which matches the exception I get when running/testing DebugFat:

System.TypeLoadException : Could not load type 'CORINFO_METHOD_INFO' from assembly 'System.Runtime.Serialization.Formatters, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

which is also randomly giving other assemblies (so not related to System.Runtime.Serialization.Formatters at all).

Quote from @nike4613 in the discord:

  • InvokeCompileMethod there is a property which returns a function pointer, which is immediately invoked
  • this is emitted as a calli
  • you'll notice, one of the parameters is a V21.CORINFO_METHOD_INFO*
  • i think that the repacker is messing up the calli signature in exactly the same way that monomod's calli emitter was
  • so one way or another, the sig asks for CORINFO_METHOD_INFO, but that somehow has the wrong 'context' token

If you want to discuss this issue, you are welcome to temporarily join my discord server. The channel is called harmony-contributors.

Should the NuGet package be marked as a development dependency?

Hi,
I tried attaching the ILRepack.Lib.MSBuild.Task nuget package to a project of mine to test, and noticed that my created nuget package has a dependency on ILRepack.Lib.MSBuild.Task itself.

I can add a PrivateAssets="all" to the PackageReference in my project myself to avoid it, but I wonder if nuget package here should maybe have a <developmentDependency>true</developmentDependency> in it so that gets done automatically?

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.