Skip to content

Commit 610ade7

Browse files
dellis1972jonpryor
authored andcommitted
[Xamarin.Android.Build.Tasks] ILRepack the NuGet.* Tasks Dependencies. (#1694)
`<ResolveAssemblies/>` is throwing the following error on a newer mono versions (2018-04): error : Could not load file or assembly 'NuGet.ProjectModel, Version=4.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. This is because we took a dependency on NuGet.ProjectModel 4.6 and the newer mono has 4.7. We cannot always be sure which version of the NuGet assemblies will be installed since users are able to upgrade mono independently. Instead, use the `ILRepack` NuGet to package up the dependencies we need so that `Xamarin.Android.Build.Tasks.dll` contains all the correct assemblies it needs.
1 parent 88ef36b commit 610ade7

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Target Name="ILRepacker" AfterTargets="Build">
4+
<ItemGroup>
5+
<InputAssemblies Include="$(OutputPath)\NuGet.ProjectModel.dll" />
6+
<InputAssemblies Include="$(OutputPath)\Newtonsoft.Json.dll" />
7+
<InputAssemblies Include="$(OutputPath)\NuGet.Common.dll" />
8+
<InputAssemblies Include="$(OutputPath)\NuGet.Common.dll" />
9+
<InputAssemblies Include="$(OutputPath)\NuGet.Frameworks.dll" />
10+
<InputAssemblies Include="$(OutputPath)\NuGet.LibraryModel.dll" />
11+
<InputAssemblies Include="$(OutputPath)\NuGet.Versioning.dll" />
12+
<InputAssemblies Include="$(OutputPath)\NuGet.Packaging.dll" />
13+
<InputAssemblies Include="$(OutputPath)\NuGet.Packaging.Core.dll" />
14+
<InputAssemblies Include="$(OutputPath)\NuGet.DependencyResolver.Core.dll" />
15+
<InputAssemblies Include="$(OutputPath)\NuGet.Configuration.dll" />
16+
</ItemGroup>
17+
<ILRepack Parallel="true"
18+
Internalize="true"
19+
Verbose="true"
20+
DebugInfo="true"
21+
InternalizeExclude="@(DoNotInternalizeAssemblies)"
22+
InputAssemblies="$(OutputPath)\$(AssemblyName).dll;@(InputAssemblies)"
23+
LibraryPath="$(OutputPath)"
24+
TargetKind="Dll"
25+
OutputFile="$(OutputPath)\$(AssemblyName).dll"
26+
/>
27+
<Delete Files="@(InputAssemblies)" />
28+
</Target>
29+
</Project>

src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@
585585
</ItemGroup>
586586
<ItemGroup>
587587
<None Include="Xamarin.Android.Build.Tasks.targets" />
588+
<None Include="ILRepack.targets" />
588589
<None Include="packages.config" />
589590
</ItemGroup>
590591
<ItemGroup>
@@ -733,4 +734,5 @@
733734
<Folder Include="Linker\Linker\" />
734735
<Folder Include="utils\" />
735736
</ItemGroup>
737+
<Import Project="..\..\packages\ILRepack.Lib.MSBuild.Task.2.0.15.4\build\ILRepack.Lib.MSBuild.Task.targets" Condition="Exists('..\..\packages\ILRepack.Lib.MSBuild.Task.2.0.15.4\build\ILRepack.Lib.MSBuild.Task.targets')" />
736738
</Project>

src/Xamarin.Android.Build.Tasks/packages.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616
<package id="NuGet.Versioning" version="4.6.0" targetFramework="net462" />
1717
<package id="System.Runtime" version="4.3.0" targetFramework="net462" />
1818
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net462" />
19-
</packages>
19+
<package id="ILRepack.Lib.MSBuild.Task" version="2.0.15.4" targetFramework="net462" />
20+
</packages>

0 commit comments

Comments
 (0)