diff --git a/build.fsx b/build.fsx
index ffb252c138..dbff80606a 100644
--- a/build.fsx
+++ b/build.fsx
@@ -322,7 +322,7 @@ Target "QuickIntegrationTests" (fun _ ->
// --------------------------------------------------------------------------------------
// Build a NuGet package
-let mergeLibs = ["paket.exe"; "Paket.Core.dll"; "FSharp.Core.dll"; "Newtonsoft.Json.dll"; "Argu.dll"; "Chessie.dll"; "Mono.Cecil.dll"]
+let mergeLibs = ["paket.exe"; "Paket.Core.dll"; "FSharp.Core.dll"; "Newtonsoft.Json.dll"; "Argu.dll"; "Chessie.dll"]
Target "MergePaketTool" (fun _ ->
CreateDir buildMergedDir
diff --git a/paket.dependencies b/paket.dependencies
index b404b5b699..8a2478c090 100644
--- a/paket.dependencies
+++ b/paket.dependencies
@@ -5,7 +5,7 @@ nuget Newtonsoft.Json redirects: force
nuget Argu >= 5.1.0
nuget FSharp.Core redirects: force
nuget Chessie >= 0.6
-nuget Mono.Cecil prerelease
+nuget System.Reflection.Metadata ~> 1.6.0 prerelease
nuget System.Security.Cryptography.ProtectedData
diff --git a/paket.lock b/paket.lock
index 86c9994c9b..a76c9eb91a 100644
--- a/paket.lock
+++ b/paket.lock
@@ -226,15 +226,6 @@ NUGET
NETStandard.Library (>= 1.6.1) - restriction: && (< monoandroid) (< monotouch) (< net46) (>= netstandard1.3) (< netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)
System.Security.AccessControl (>= 4.4) - restriction: || (>= monoandroid) (>= monotouch) (&& (< net46) (>= netstandard2.0)) (>= net461) (>= netcoreapp2.0) (>= xamarinios) (>= xamarinmac) (>= xamarintvos) (>= xamarinwatchos)
System.Security.Principal.Windows (>= 4.4) - restriction: || (>= monoandroid) (>= monotouch) (&& (< net46) (>= netstandard2.0)) (>= net461) (>= netcoreapp2.0) (>= xamarinios) (>= xamarinmac) (>= xamarintvos) (>= xamarinwatchos)
- Mono.Cecil (0.10.0-beta6)
- System.Collections (>= 4.0.11) - restriction: && (< net35) (>= netstandard1.3)
- System.IO.FileSystem (>= 4.0.1) - restriction: && (< net35) (>= netstandard1.3)
- System.IO.FileSystem.Primitives (>= 4.0.1) - restriction: && (< net35) (>= netstandard1.3)
- System.Reflection (>= 4.1) - restriction: && (< net35) (>= netstandard1.3)
- System.Runtime.Extensions (>= 4.1) - restriction: && (< net35) (>= netstandard1.3)
- System.Security.Cryptography.Algorithms (>= 4.2) - restriction: && (< net35) (>= netstandard1.3)
- System.Security.Cryptography.Csp (>= 4.0) - restriction: && (< net35) (>= netstandard1.3)
- System.Threading (>= 4.0.11) - restriction: && (< net35) (>= netstandard1.3)
Moq (4.7.99)
Castle.Core (>= 4.1.1) - restriction: || (>= net45) (>= netstandard1.3)
NETStandard.Library (>= 1.6.1) - restriction: && (< net45) (>= netstandard1.3)
@@ -398,8 +389,8 @@ NUGET
System.Runtime.Extensions (>= 4.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.3) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (< portable-net45+win8+wpa81)
System.Threading (>= 4.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.3) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (< portable-net45+win8+wpa81)
System.Threading.Tasks (>= 4.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.3) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (>= netstandard1.1) (< netstandard1.3) (< win8) (< wpa81)) (< portable-net45+win8+wpa81)
- System.Collections.Immutable (1.4) - restriction: || (&& (>= monoandroid) (>= netcoreapp1.0)) (&& (>= monoandroid) (>= netcoreapp1.1)) (&& (>= monotouch) (>= netcoreapp1.0)) (&& (>= monotouch) (>= netcoreapp1.1)) (&& (>= netcoreapp1.0) (< netcoreapp1.1) (>= netstandard2.0)) (&& (>= netcoreapp1.0) (< netcoreapp1.1) (< netstandard2.0)) (&& (>= netcoreapp1.0) (< netstandard1.1)) (&& (>= netcoreapp1.0) (< portable-net45+win8)) (&& (>= netcoreapp1.0) (>= xamarinios)) (&& (>= netcoreapp1.0) (>= xamarinmac)) (&& (>= netcoreapp1.0) (>= xamarintvos)) (&& (>= netcoreapp1.0) (>= xamarinwatchos)) (&& (>= netcoreapp1.1) (< netcoreapp2.0) (>= netstandard2.0)) (&& (>= netcoreapp1.1) (< netstandard1.1)) (&& (>= netcoreapp1.1) (< netstandard2.0)) (&& (>= netcoreapp1.1) (< portable-net45+win8)) (&& (>= netcoreapp1.1) (>= xamarinios)) (&& (>= netcoreapp1.1) (>= xamarinmac)) (&& (>= netcoreapp1.1) (>= xamarintvos)) (&& (>= netcoreapp1.1) (>= xamarinwatchos))
- NETStandard.Library (>= 1.6.1) - restriction: && (>= netstandard1.0) (< netstandard2.0) (< xamarinmac)
+ System.Collections.Immutable (1.5.0-rc1) - restriction: || (>= net45) (&& (< netcoreapp2.1) (>= netstandard2.0)) (&& (>= netstandard1.1) (< netstandard2.0) (< win8) (< wpa81)) (&& (< netstandard1.1) (>= portable-net45+win8+wpa81) (< win8)) (&& (< netstandard1.1) (>= win8)) (&& (< netstandard2.0) (>= wpa81))
+ NETStandard.Library (>= 1.6.1) - restriction: || (&& (< net45) (>= netstandard1.0) (< netstandard1.3) (< win8) (< wp8) (< wpa81)) (&& (< net45) (>= netstandard1.3) (< netstandard2.0) (< win8) (< wpa81))
System.Collections.NonGeneric (4.3) - redirects: force, restriction: || (&& (< monoandroid) (< monotouch) (< net20) (>= netstandard1.5) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net20) (< netstandard1.3) (>= netstandard1.5) (< win8) (< wpa81)) (&& (< net20) (>= net462))
System.Diagnostics.Debug (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net46) (>= netstandard1.3) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)
System.Globalization (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net46) (>= netstandard1.3) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)
@@ -819,9 +810,9 @@ NUGET
Microsoft.NETCore.Targets (>= 1.1) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< win8) (< wp8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (< portable-net45+win8+wp8+wpa81)
System.Reflection (>= 4.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< win8) (< wp8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (< portable-net45+win8+wp8+wpa81)
System.Runtime (>= 4.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< win8) (< wp8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (< portable-net45+win8+wp8+wpa81)
- System.Reflection.Metadata (1.5) - restriction: || (&& (>= netcoreapp1.0) (< netcoreapp1.1)) (&& (>= netcoreapp1.1) (< netcoreapp2.0))
- NETStandard.Library (>= 1.6.1) - restriction: && (< monoandroid) (< monotouch) (>= netstandard1.1) (< netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)
- System.Collections.Immutable (>= 1.4) - restriction: || (>= monoandroid) (>= monotouch) (&& (< netcoreapp2.0) (>= netstandard2.0)) (&& (>= netstandard1.1) (< netstandard2.0)) (&& (< netstandard1.1) (>= portable-net45+win8)) (&& (< portable-net45+win8) (>= portable-net45+win8+wpa81)) (>= xamarinios) (>= xamarinmac) (>= xamarintvos) (>= xamarinwatchos)
+ System.Reflection.Metadata (1.6.0-rc1)
+ NETStandard.Library (>= 1.6.1) - restriction: && (< net45) (>= netstandard1.1) (< netstandard2.0) (< win8) (< wpa81)
+ System.Collections.Immutable (>= 1.5.0-rc1) - restriction: || (>= net45) (&& (< netcoreapp2.1) (>= netstandard2.0)) (&& (>= netstandard1.1) (< netstandard2.0) (< win8) (< wpa81)) (&& (< netstandard1.1) (>= portable-net45+win8+wpa81) (< win8)) (&& (< netstandard1.1) (>= win8)) (&& (< netstandard2.0) (>= wpa81))
System.Reflection.Primitives (4.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.6) (< netstandard2.0) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (>= netstandard1.2) (< netstandard1.3) (< wpa81)) (&& (< monoandroid) (< net45) (>= netstandard1.3) (< netstandard1.4) (< wpa81)) (&& (< monoandroid) (< net45) (>= netstandard1.4) (< netstandard1.5) (< wpa81)) (&& (< monoandroid) (< net45) (>= netstandard1.5) (< netstandard1.6) (< wpa81)) (&& (< net45) (>= netstandard1.1) (< portable-net451+win81+wpa81)) (&& (>= netstandard1.0) (< portable-net45+win8+wpa81)) (&& (< netstandard1.5) (>= uap10.0) (< uap10.1))
Microsoft.NETCore.Platforms (>= 1.1) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< win8) (< wp8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (< portable-net45+win8+wp8+wpa81)
Microsoft.NETCore.Targets (>= 1.1) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< win8) (< wp8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (< portable-net45+win8+wp8+wpa81)
@@ -923,7 +914,7 @@ NUGET
System.Security.Cryptography.Encoding (>= 4.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net46) (>= netstandard1.6) (< netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net46) (>= netstandard1.4) (< netstandard1.6))
System.Security.Cryptography.Primitives (>= 4.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net46) (>= netstandard1.6) (< netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net46) (>= netstandard1.3) (< netstandard1.4)) (&& (< monoandroid) (< net46) (>= netstandard1.4) (< netstandard1.6)) (&& (>= net46) (< netstandard1.4))
System.Text.Encoding (>= 4.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net46) (>= netstandard1.6) (< netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net46) (>= netstandard1.4) (< netstandard1.6))
- System.Security.Cryptography.Csp (4.3) - restriction: && (< net35) (>= netstandard1.3)
+ System.Security.Cryptography.Csp (4.3) - restriction: || (&& (>= netcoreapp1.0) (< netcoreapp1.1)) (&& (>= netcoreapp1.1) (< netcoreapp2.0))
Microsoft.NETCore.Platforms (>= 1.1) - restriction: && (< monoandroid) (< monotouch) (< net46) (>= netstandard1.3) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)
System.IO (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net46) (>= netstandard1.3) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)
System.Reflection (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net46) (>= netstandard1.3) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)
diff --git a/src/Paket.Core.preview3/Paket.Core.fsproj b/src/Paket.Core.preview3/Paket.Core.fsproj
index c9b427fb7e..fb2d4664df 100644
--- a/src/Paket.Core.preview3/Paket.Core.fsproj
+++ b/src/Paket.Core.preview3/Paket.Core.fsproj
@@ -19,6 +19,7 @@
True
Globbing.fs
+
diff --git a/src/Paket.Core.preview3/paket.references b/src/Paket.Core.preview3/paket.references
index 857f2e623a..f2fe81072f 100644
--- a/src/Paket.Core.preview3/paket.references
+++ b/src/Paket.Core.preview3/paket.references
@@ -1,5 +1,5 @@
Newtonsoft.Json
-Mono.Cecil
+System.Reflection.Metadata
Chessie
System.Security.Cryptography.ProtectedData
diff --git a/src/Paket.Core/Common/AssemblyMetadata.fs b/src/Paket.Core/Common/AssemblyMetadata.fs
new file mode 100644
index 0000000000..8649a94778
--- /dev/null
+++ b/src/Paket.Core/Common/AssemblyMetadata.fs
@@ -0,0 +1,74 @@
+module Paket.AssemblyMetadata
+
+open Chessie.ErrorHandling
+open System
+open System.IO
+open System.Globalization
+open System.Reflection
+open System.Reflection
+open System.Reflection.Metadata
+open System.Reflection.PortableExecutable
+
+/// Calculates the short form of the public key token for use with binding redirects, if it exists.
+let getPublicKeyToken (assembly:AssemblyName) =
+ ("", assembly.GetPublicKeyToken())
+ ||> Array.fold(fun state b -> state + b.ToString("X2"))
+ |> function
+ | "" -> None
+ | token -> Some (token.ToLower())
+
+/// Creates AssemblyName of AssemblyReference opened on the MetadataReader;
+/// expected to be part of next release of the Metadata support, so we can remove this.
+/// Can throw AccessViolation if used incorrectly, with unrelated or disposed reader.
+let private getAssemblyName (reader:MetadataReader) (reference:AssemblyReference) =
+ let assemblyName = reader.GetString(reference.Name)
+ let cultureInfo =
+ if reference.Culture.IsNil then null
+ else CultureInfo(reader.GetString(reference.Culture))
+ let hasPublicKey = reference.Flags.HasFlag(AssemblyFlags.PublicKey)
+ let assemblyFlag =
+ if hasPublicKey then AssemblyNameFlags.PublicKey else AssemblyNameFlags.None
+ let assemblyName =
+ new AssemblyName(
+ Name = assemblyName,
+ Flags = assemblyFlag,
+ Version = reference.Version,
+ CultureInfo = cultureInfo)
+ let keyOrToken =
+ let keyOrTokenHandle = reference.PublicKeyOrToken
+ if keyOrTokenHandle.IsNil then null else reader.GetBlobBytes(keyOrTokenHandle)
+ if hasPublicKey then
+ assemblyName.SetPublicKey(keyOrToken)
+ else
+ assemblyName.SetPublicKeyToken(keyOrToken)
+ assemblyName;
+
+type AssemblyDefinition =
+ | AssemblyFile of String
+ | AssemblyInfo of FileInfo
+ | AssemblyName of AssemblyName
+
+/// Uses the assembly file metadata from the provided source,
+/// to return AssemblyName list of its referenced assemblies.
+let getAssemblyReferences (assembly:AssemblyDefinition) =
+ try
+ let assemblyFilePath =
+ match assembly with
+ | AssemblyFile file -> file
+ | AssemblyInfo info -> info.FullName
+ | AssemblyName name -> Uri(name.CodeBase).LocalPath
+ use file = File.OpenRead(assemblyFilePath)
+ use reader = new PEReader(file, PEStreamOptions.PrefetchMetadata)
+ let metadataReader = reader.GetMetadataReader()
+ metadataReader.AssemblyReferences
+ |> Seq.map (fun aref ->
+ try
+ let reference = metadataReader.GetAssemblyReference(aref)
+ pass(getAssemblyName metadataReader reference)
+ with
+ | ex -> fail ex)
+ |> collect
+ with
+ | ex -> fail ex
+
+
diff --git a/src/Paket.Core/Installation/BindingRedirects.fs b/src/Paket.Core/Installation/BindingRedirects.fs
index f4dab17de8..6931af9456 100644
--- a/src/Paket.Core/Installation/BindingRedirects.fs
+++ b/src/Paket.Core/Installation/BindingRedirects.fs
@@ -194,11 +194,3 @@ let applyBindingRedirectsToFolder isFirstGroup createNewBindingFiles cleanBindin
for p in projects do
applyBindingRedirects p
-
-/// Calculates the short form of the public key token for use with binding redirects, if it exists.
-let getPublicKeyToken (assembly:Mono.Cecil.AssemblyDefinition) =
- ("", assembly.Name.PublicKeyToken)
- ||> Array.fold(fun state b -> state + b.ToString("X2"))
- |> function
- | "" -> None
- | token -> Some (token.ToLower())
diff --git a/src/Paket.Core/Installation/InstallProcess.fs b/src/Paket.Core/Installation/InstallProcess.fs
index 0c0de1954d..f8832fa526 100644
--- a/src/Paket.Core/Installation/InstallProcess.fs
+++ b/src/Paket.Core/Installation/InstallProcess.fs
@@ -2,15 +2,18 @@
module Paket.InstallProcess
open Paket
+open System
open Chessie.ErrorHandling
+open Paket
open Paket.Domain
open Paket.Logging
open Paket.BindingRedirects
open System.IO
open Paket.PackageSources
open Paket.Requirements
+open ProviderImplementation.AssemblyReader
open System.Collections.Generic
-open System
+open System.Reflection
let updatePackagesConfigFile (model: Map) packagesConfigFileName =
let packagesInConfigFile = PackagesConfigFile.Read packagesConfigFileName
@@ -293,20 +296,31 @@ let private applyBindingRedirects isFirstGroup createNewBindingFiles cleanBindin
librariesForPackage
|> Seq.choose(fun (library,redirects,profile) ->
try
- let assembly = Mono.Cecil.AssemblyDefinition.ReadAssembly(library.Path)
- Some (assembly, BindingRedirects.getPublicKeyToken assembly, assembly.MainModule.AssemblyReferences, redirects, profile)
+ let assemblyName = AssemblyName.GetAssemblyName(library.Path)
+ let publicKeyToken = AssemblyMetadata.getPublicKeyToken assemblyName
+ let metadataName = AssemblyMetadata.AssemblyName assemblyName
+ let references =
+ match AssemblyMetadata.getAssemblyReferences metadataName with
+ | Trial.Pass list -> list
+ | Trial.Warn(list, warn) ->
+ warn |> List.iter (fun ex -> ex |> string |> traceWarn)
+ list
+ | Trial.Fail exns ->
+ exns |> List.iter (fun ex -> ex |> string |> traceError)
+ List.empty
+ Some (assemblyName, publicKeyToken, references, redirects, profile)
with _ -> None)
- |> Seq.sortBy(fun (assembly,_,_,_,_) -> assembly.Name.Version)
+ |> Seq.sortBy(fun (assembly,_,_,_,_) -> assembly.Version)
|> Seq.toList
|> List.rev
|> function | head :: _ -> Some head | _ -> None)
|> Seq.cache
- let referencesDifferentProfiles (assemblyName : Mono.Cecil.AssemblyNameDefinition) profile =
+ let referencesDifferentProfiles (assemblyName : AssemblyName) profile =
(targetProfiles |> Seq.exists ((=) profile))
&& assemblies
|> Seq.filter (fun (_,_,_,_,p) -> p <> profile)
- |> Seq.map (fun (a,_,_,_,_) -> a.Name)
+ |> Seq.map (fun (a,_,_,_,_) -> a)
|> Seq.filter (fun a -> a.Name = assemblyName.Name)
|> Seq.exists (fun a -> a.Version <> assemblyName.Version)
@@ -320,7 +334,7 @@ let private applyBindingRedirects isFirstGroup createNewBindingFiles cleanBindin
| Some BindingRedirectsSettings.Off -> false
| _ -> false)
|> Seq.filter (fun (assembly,_,_,redirects,profile) ->
- let assemblyName = assembly.Name
+ let assemblyName = assembly
redirects = Some BindingRedirectsSettings.Force
|| referencesDifferentProfiles assemblyName profile
|| assemblies
@@ -328,8 +342,8 @@ let private applyBindingRedirects isFirstGroup createNewBindingFiles cleanBindin
|> Seq.filter (fun a -> assemblyName.Name = a.Name)
|> Seq.exists (fun a -> assemblyName.Version > a.Version))
|> Seq.map(fun (assembly, token,_,_,_) ->
- { BindingRedirect.AssemblyName = assembly.Name.Name
- Version = assembly.Name.Version.ToString()
+ { BindingRedirect.AssemblyName = assembly.Name
+ Version = assembly.Version.ToString()
PublicKeyToken = token
Culture = None })
|> Seq.sort
diff --git a/src/Paket.Core/Paket.Core.fsproj b/src/Paket.Core/Paket.Core.fsproj
index 0d52a9c654..eb2cbdf713 100644
--- a/src/Paket.Core/Paket.Core.fsproj
+++ b/src/Paket.Core/Paket.Core.fsproj
@@ -62,6 +62,7 @@
+
@@ -310,6 +311,7 @@
+
@@ -534,6 +536,44 @@
+
+
+
+
+ ..\..\packages\System.Collections.Immutable\lib\netstandard1.0\System.Collections.Immutable.dll
+ True
+ True
+
+
+
+
+
+
+ ..\..\packages\System.Collections.Immutable\lib\netstandard1.3\System.Collections.Immutable.dll
+ True
+ True
+
+
+
+
+
+
+ ..\..\packages\System.Collections.Immutable\lib\netstandard2.0\System.Collections.Immutable.dll
+ True
+ True
+
+
+
+
+
+
+ ..\..\packages\System.Collections.Immutable\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll
+ True
+ True
+
+
+
+
@@ -1239,6 +1279,35 @@
+
+
+
+
+ ..\..\packages\System.Reflection.Metadata\lib\netstandard1.1\System.Reflection.Metadata.dll
+ True
+ True
+
+
+
+
+
+
+ ..\..\packages\System.Reflection.Metadata\lib\netstandard2.0\System.Reflection.Metadata.dll
+ True
+ True
+
+
+
+
+
+
+ ..\..\packages\System.Reflection.Metadata\lib\portable-net45+win8\System.Reflection.Metadata.dll
+ True
+ True
+
+
+
+
diff --git a/src/Paket.Core/PaketConfigFiles/DependencyCache.fs b/src/Paket.Core/PaketConfigFiles/DependencyCache.fs
index 6563392155..0e88ad9bd0 100644
--- a/src/Paket.Core/PaketConfigFiles/DependencyCache.fs
+++ b/src/Paket.Core/PaketConfigFiles/DependencyCache.fs
@@ -1,14 +1,16 @@
namespace Paket
+open Chessie.ErrorHandling
open System.IO
open Paket.Domain
open System.Collections.Concurrent
open PackageResolver
-open Mono.Cecil
open System.Collections.Generic
open Logging
open ProviderImplementation.AssemblyReader.Utils.SHA1
+open Requirements
open System
+open System.Reflection
// Needs an update so that all work is not done at once
// computation should be done on a per group/per framework basis
@@ -84,14 +86,25 @@ type DependencyCache (lockFile:LockFile) =
do loadPackages ()
- let getDllOrder (dllFiles : AssemblyDefinition list) =
+ let getDllOrder (dllFiles : AssemblyName list) =
// this check saves looking at assembly metadata when we know this is not needed
if List.length dllFiles = 1 then dllFiles else
// we ignore all unknown references as they are most likely resolved on package level
let known = dllFiles |> Seq.map (fun a -> a.FullName) |> Set.ofSeq
getPackageOrderGeneric
- (fun (p:AssemblyDefinition) -> p.FullName)
- (fun p -> p.MainModule.AssemblyReferences |> Seq.map (fun r -> r.FullName) |> Seq.filter (known.Contains))
+ (fun (p:AssemblyName) -> p.FullName)
+ (fun p ->
+ let assemblyName = AssemblyMetadata.AssemblyName p
+ match AssemblyMetadata.getAssemblyReferences assemblyName with
+ | Trial.Pass list -> list
+ | Trial.Warn(list, warn) ->
+ warn |> List.iter (fun ex -> ex |> string |> traceWarn)
+ list
+ | Trial.Fail exns ->
+ exns |> List.iter (fun ex -> ex |> string |> traceError)
+ List.empty
+ |> Seq.map (fun r -> r.FullName)
+ |> Seq.filter (known.Contains))
dllFiles
@@ -102,7 +115,7 @@ type DependencyCache (lockFile:LockFile) =
|> Seq.map (fun l -> l.Path)
|> Seq.choose (fun path ->
try
- (AssemblyDefinition.ReadAssembly path, FileInfo(path)) |> Some
+ (AssemblyName.GetAssemblyName(path), FileInfo(path)) |> Some
with
| :? BadImageFormatException -> None
)
@@ -130,7 +143,7 @@ type DependencyCache (lockFile:LockFile) =
let assemblyFilePerAssemblyDef =
libs |> Seq.choose (fun (f:FileInfo) ->
try
- (AssemblyDefinition.ReadAssembly (f.FullName:string), f) |> Some
+ (AssemblyName.GetAssemblyName(f.FullName:string), f) |> Some
with
| :? BadImageFormatException -> None)
|> dict
diff --git a/src/Paket.Core/paket.references b/src/Paket.Core/paket.references
index 00c24884cd..2d91744234 100644
--- a/src/Paket.Core/paket.references
+++ b/src/Paket.Core/paket.references
@@ -1,9 +1,9 @@
Newtonsoft.Json
FSharp.Core
-Mono.Cecil
Chessie
FSharp.Compiler.Tools
System.Net.Http
+System.Reflection.Metadata
File:Globbing.fs Common\
File:AssemblyReader.fs Common\