@@ -89,7 +89,8 @@ let paketCachingProvider printDetails cacheDir (paketDependencies:Paket.Dependen
89
89
let groupStr = match group with Some g -> g | None -> " Main"
90
90
let groupName = Paket.Domain.GroupName ( groupStr)
91
91
#if DOTNETCORE
92
- let framework = Paket.FrameworkIdentifier.DotNetCoreApp ( Paket.DotNetCoreAppVersion.V2_ 0)
92
+ //let framework = Paket.FrameworkIdentifier.DotNetCoreApp (Paket.DotNetCoreAppVersion.V2_0)
93
+ let framework = Paket.FrameworkIdentifier.DotNetStandard ( Paket.DotNetStandardVersion.V2_ 0)
93
94
#else
94
95
let framework = Paket.FrameworkIdentifier.DotNetFramework ( Paket.FrameworkVersion.V4_ 6)
95
96
#endif
@@ -99,8 +100,36 @@ let paketCachingProvider printDetails cacheDir (paketDependencies:Paket.Dependen
99
100
100
101
#if DOTNETCORE
101
102
let getCurrentSDKReferenceFiles () =
102
- let netstandard = System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromAssemblyName( System.Reflection.AssemblyName( " netstandard" ))
103
- let sdkDir = Path.GetDirectoryName netstandard.Location
103
+ // We need use "real" reference assemblies as using the currently running runtime assemlies doesn't work:
104
+ // see https://github.com/fsharp/FAKE/pull/1695
105
+
106
+ // Therefore we download the reference assemblies (the NETStandard.Library package)
107
+ // and add them in addition to what we have resolved,
108
+ // we use the sources in the paket.dependencies to give the user a chance to overwrite.
109
+
110
+ // Note: This package/version needs to updated together with our "framework" variable below and needs to
111
+ // be compatible with the runtime we are currently running on.
112
+ let rootDir = Directory.GetCurrentDirectory()
113
+ let sources = paketDependencies.GetSources().[ groupName]
114
+ let packageName = Domain.PackageName( " NETStandard.Library" )
115
+ let version = SemVer.Parse( " 2.0.0" )
116
+ let versions =
117
+ Paket.NuGet.GetVersions false None rootDir ( PackageResolver.GetPackageVersionsParameters.ofParams sources groupName packageName)
118
+ |> Async.RunSynchronously
119
+ |> dict
120
+ let source =
121
+ match versions.TryGetValue( version) with
122
+ | true , v when v.Length > 0 -> v |> Seq.head
123
+ | _ -> failwithf " Could not find package '%A ' with version '%A ' in any package source of group '%A ', but paket needs this package for compilation" packageName version groupName
124
+
125
+ let _ , extractedFolder =
126
+ Paket.NuGet.DownloadAndExtractPackage
127
+ ( None, rootDir, false , PackagesFolderGroupConfig.NoPackagesFolder,
128
+ source, [], Paket.Constants.MainDependencyGroup,
129
+ packageName, version, false , false , false , false )
130
+ |> Async.RunSynchronously
131
+ //let netstandard = System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromAssemblyName(System.Reflection.AssemblyName("netstandard"))
132
+ let sdkDir = Path.Combine( extractedFolder, " build" , " netstandard2.0" , " ref" )
104
133
Directory.GetFiles( sdkDir, " *.dll" )
105
134
|> Seq.toList
106
135
#endif
@@ -190,26 +219,6 @@ let paketCachingProvider printDetails cacheDir (paketDependencies:Paket.Dependen
190
219
|> Seq.choose ( fun ( isSdk , isReferenceAssembly , fi ) ->
191
220
let fullName = fi.FullName
192
221
try let assembly = Mono.Cecil.AssemblyDefinition.ReadAssembly fullName
193
- let takeAssembly =
194
- if not isSdk then true
195
- else
196
- let isFramework =
197
- assembly.CustomAttributes |> Seq.exists ( fun attr ->
198
- if attr.AttributeType.Name = " AssemblyMetadataAttribute" then
199
- let arg1 = attr.ConstructorArguments.[ 0 ]
200
- let value1 = arg1.Value.ToString()
201
- let arg2 = attr.ConstructorArguments.[ 1 ]
202
- let value2 = arg2.Value.ToString()
203
- value1 = " .NETFrameworkAssembly" ||
204
- ( value1 = " Serviceable" && value2 = " True" )
205
-
206
- else false )
207
- isFramework
208
- if not takeAssembly then
209
- if printDetails then Trace.log <| sprintf " Not taking '%s '" fullName
210
- None
211
- else
212
-
213
222
{ IsReferenceAssembly = isReferenceAssembly
214
223
Info =
215
224
{ Runners.AssemblyInfo.FullName = assembly.Name.FullName
@@ -220,7 +229,7 @@ let paketCachingProvider printDetails cacheDir (paketDependencies:Paket.Dependen
220
229
|> Seq.groupBy ( fun ass -> ass.IsReferenceAssembly, System.Reflection.AssemblyName( ass.Info.FullName) .Name)
221
230
|> Seq.map ( fun ( _ , group ) -> group |> Seq.maxBy( fun ass -> ass.Info.Version))
222
231
|> Seq.toList
223
- //|> List.partition (fun c -> c.IsReferenceAssembly)
232
+
224
233
// Restore or update immediatly, because or everything might be OK -> cached path.
225
234
let knownAssemblies = restoreOrUpdate()
226
235
if printDetails then
0 commit comments