Skip to content

Commit

Permalink
Update to ILRepack 2.0.29 (#50)
Browse files Browse the repository at this point in the history
Adds new task parameter item: InternalizeAssembly - a list of specific assembly names to internalize.
  • Loading branch information
KirillOsenkov authored Apr 1, 2024
1 parent 25a8fc3 commit fe6a8b2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
6 changes: 3 additions & 3 deletions ILRepack.Lib.MSBuild.Task/ILRepack.Lib.MSBuild.Task.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<Version>2.0.26</Version>
<Version>2.0.29</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ILRepack" Version="2.0.26" GeneratePathProperty="true"/>
<PackageReference Include="ILRepack.Lib" Version="2.0.26"/>
<PackageReference Include="ILRepack" Version="2.0.29" GeneratePathProperty="true"/>
<PackageReference Include="ILRepack.Lib" Version="2.0.29"/>
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.8.3"/>
</ItemGroup>

Expand Down
30 changes: 30 additions & 0 deletions ILRepack.Lib.MSBuild.Task/ILRepack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ public virtual string TargetKind
/// </summary>
public virtual ITaskItem[] InternalizeExclude { get; set; }

/// <summary>
/// List of specific assemblies to internalize.
/// </summary>
public virtual ITaskItem[] InternalizeAssembly { get; set; }

/// <summary>
/// Output name for the merged assembly.
/// </summary>
Expand Down Expand Up @@ -321,6 +326,11 @@ public override bool Execute()

repackOptions.InputAssemblies = assemblies;

if (InternalizeAssembly != null && InternalizeAssembly.Any())
{
repackOptions.InternalizeAssemblies = InternalizeAssembly.Select(i => StripExtension(i.ItemSpec)).ToArray();
}

// Path that will be used when searching for assemblies to merge.
var searchPath = new List<string> { "." };
searchPath.AddRange(LibraryPath.Select(iti => BuildPath(iti.ItemSpec)));
Expand Down Expand Up @@ -393,6 +403,26 @@ private static string BuildPath(string path)
return string.IsNullOrEmpty(path) ? null : Path.Combine(workDir, path);
}

/// <summary>
/// Strips .dll or .exe extension from filePath if present.
/// </summary>
/// <param name="filePath">File path</param>
/// <returns>File path without the extension.</returns>
private static string StripExtension(string filePath)
{
if (filePath == null)
{
return null;
}

if (filePath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) || filePath.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
{
filePath = filePath.Substring(0, filePath.Length - 4);
}

return filePath;
}

#endregion

#region IDisposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>ILRepack.Lib.MSBuild.Task</id>
<version>2.0.26</version>
<version>2.0.29</version>
<title>ILRepack.Lib.MSBuild.Task</title>
<authors>RBSoft</authors>
<owners>rbsoft</owners>
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ You can turn this functionality off by setting ClearOutputDirectory to False as
| XmlDocumentation | Merge assembly XML documentation. |
| LibraryPath | List of paths to use as "include directories" when attempting to merge assemblies. |
| Internalize | Set all types but the ones from the first assembly 'internal'. |
| InternalizeAssembly | Internalize only specific assemblies (list of assembly names without path or extension). |
| RenameInternalized | Rename all internalized types (to be used when Internalize is enabled). |
| ExcludeInternalizeSerializable | Do not internalize types marked as Serializable. |
| InternalizeExclude | If Internalize is set to true, any which match these regular expressions will not be internalized. If Internalize is false, then this property is ignored. |
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2.0.26.{build}
version: 2.0.29.{build}
environment:
my_version: 2.0.26
my_version: 2.0.29
my_secret:
secure: 5qtuEW0UQ/IEO8DRi4/y3EgEBoJDM/HyYpPgzasIlm0=
skip_branch_with_pr: true
Expand Down

0 comments on commit fe6a8b2

Please sign in to comment.