Skip to content

Commit

Permalink
[Xamarin.Android.Build.Tasks] ILRepack the NuGet.* Tasks Dependencies. (
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
dellis1972 authored and jonpryor committed May 18, 2018
1 parent 88ef36b commit 610ade7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
29 changes: 29 additions & 0 deletions src/Xamarin.Android.Build.Tasks/ILRepack.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="ILRepacker" AfterTargets="Build">
<ItemGroup>
<InputAssemblies Include="$(OutputPath)\NuGet.ProjectModel.dll" />
<InputAssemblies Include="$(OutputPath)\Newtonsoft.Json.dll" />
<InputAssemblies Include="$(OutputPath)\NuGet.Common.dll" />
<InputAssemblies Include="$(OutputPath)\NuGet.Common.dll" />
<InputAssemblies Include="$(OutputPath)\NuGet.Frameworks.dll" />
<InputAssemblies Include="$(OutputPath)\NuGet.LibraryModel.dll" />
<InputAssemblies Include="$(OutputPath)\NuGet.Versioning.dll" />
<InputAssemblies Include="$(OutputPath)\NuGet.Packaging.dll" />
<InputAssemblies Include="$(OutputPath)\NuGet.Packaging.Core.dll" />
<InputAssemblies Include="$(OutputPath)\NuGet.DependencyResolver.Core.dll" />
<InputAssemblies Include="$(OutputPath)\NuGet.Configuration.dll" />
</ItemGroup>
<ILRepack Parallel="true"
Internalize="true"
Verbose="true"
DebugInfo="true"
InternalizeExclude="@(DoNotInternalizeAssemblies)"
InputAssemblies="$(OutputPath)\$(AssemblyName).dll;@(InputAssemblies)"
LibraryPath="$(OutputPath)"
TargetKind="Dll"
OutputFile="$(OutputPath)\$(AssemblyName).dll"
/>
<Delete Files="@(InputAssemblies)" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@
</ItemGroup>
<ItemGroup>
<None Include="Xamarin.Android.Build.Tasks.targets" />
<None Include="ILRepack.targets" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -733,4 +734,5 @@
<Folder Include="Linker\Linker\" />
<Folder Include="utils\" />
</ItemGroup>
<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')" />
</Project>
3 changes: 2 additions & 1 deletion src/Xamarin.Android.Build.Tasks/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
<package id="NuGet.Versioning" version="4.6.0" targetFramework="net462" />
<package id="System.Runtime" version="4.3.0" targetFramework="net462" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net462" />
</packages>
<package id="ILRepack.Lib.MSBuild.Task" version="2.0.15.4" targetFramework="net462" />
</packages>

0 comments on commit 610ade7

Please sign in to comment.