@@ -69,6 +69,9 @@ let SimulatedMSBuildResolver =
69
69
{ new Resolver with
70
70
member __.HighestInstalledNetFrameworkVersion () = " v4.5"
71
71
member __.DotNetFrameworkReferenceAssembliesRootDirectory =
72
+ #if RESHAPED_ MSBUILD
73
+ " "
74
+ #else
72
75
if System.Environment.OSVersion.Platform = System.PlatformID.Win32NT then
73
76
let PF =
74
77
match Environment.GetEnvironmentVariable( " ProgramFiles(x86)" ) with
@@ -77,10 +80,12 @@ let SimulatedMSBuildResolver =
77
80
PF + @" \Reference Assemblies\Microsoft\Framework\.NETFramework"
78
81
else
79
82
" "
83
+ #endif
80
84
81
85
member __.Resolve ( resolutionEnvironment , references , targetFrameworkVersion , targetFrameworkDirectories , targetProcessorArchitecture ,
82
86
outputDirectory , fsharpCoreDir , explicitIncludeDirs , implicitIncludeDir , logMessage , logWarning , logError ) =
83
87
88
+ #if ! RESHAPED_ MSBUILD
84
89
let registrySearchPaths () =
85
90
[ let registryKey = @" Software\Microsoft\.NetFramework" ;
86
91
use key = Registry.LocalMachine.OpenSubKey( registryKey)
@@ -107,23 +112,26 @@ let SimulatedMSBuildResolver =
107
112
match subSubSubKey.GetValue( null ) with
108
113
| : ? string as s -> yield s
109
114
| _ -> () ]
110
-
115
+ #endif
111
116
112
117
let results = ResizeArray()
113
118
let searchPaths =
114
119
[ yield ! targetFrameworkDirectories
115
120
yield ! explicitIncludeDirs
116
121
yield fsharpCoreDir
117
122
yield implicitIncludeDir
123
+ #if ! RESHAPED_ MSBUILD
118
124
if System.Environment.OSVersion.Platform = System.PlatformID.Win32NT then
119
- yield ! registrySearchPaths() ]
125
+ yield ! registrySearchPaths()
126
+ #endif
127
+ ]
120
128
121
129
for ( r, baggage) in references do
122
- printfn " resolving %s " r
130
+ // printfn "resolving %s" r
123
131
let mutable found = false
124
132
let success path =
125
133
if not found then
126
- printfn " resolved %s --> %s " r path
134
+ // printfn "resolved %s --> %s" r path
127
135
found <- true
128
136
results.Add { itemSpec = path; prepareToolTip = snd; baggage= baggage }
129
137
@@ -133,6 +141,7 @@ let SimulatedMSBuildResolver =
133
141
success r
134
142
with e -> logWarning " SR001" ( e.ToString())
135
143
144
+ #if ! RESHAPED_ MSBUILD
136
145
// For this one we need to get the version search exactly right, without doing a load
137
146
try
138
147
if not found && r.StartsWith( " FSharp.Core, Version=" ) && Environment.OSVersion.Platform = PlatformID.Win32NT then
@@ -147,15 +156,7 @@ let SimulatedMSBuildResolver =
147
156
if FileSystem.SafeExists( trialPath) then
148
157
success trialPath
149
158
with e -> logWarning " SR001" ( e.ToString())
150
-
151
- // Try to use Assemby.Load rather than searching paths for assemblies with explicit versions
152
- try
153
- if not found && r.Contains( " ," ) then
154
- let ass = try Some ( Assembly.Load( r)) with _ -> None
155
- match ass with
156
- | None -> ()
157
- | Some ass -> success ass.Location
158
- with e -> logWarning " SR001" ( e.ToString())
159
+ #endif
159
160
160
161
let isFileName =
161
162
r.EndsWith( " dll" , StringComparison.OrdinalIgnoreCase) ||
@@ -171,31 +172,48 @@ let SimulatedMSBuildResolver =
171
172
success trialPath
172
173
with e -> logWarning " SR001" ( e.ToString())
173
174
175
+ #if ! RESHAPED_ MSBUILD
174
176
try
175
177
// Seach the GAC on Windows
176
178
if not found && not isFileName && Environment.OSVersion.Platform = PlatformID.Win32NT then
177
179
let n = AssemblyName( r)
178
180
let netfx = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
179
181
let gac = Path.Combine( Path.GetDirectoryName( Path.GetDirectoryName( netfx.TrimEnd( '\\' ))), " assembly" )
180
- for gacdir in Directory.EnumerateDirectories( gac) do
181
- let assdir = Path.Combine( gacdir, n.Name)
182
- if Directory.Exists( assdir) then
183
- let verdir = Path.Combine( assdir, " v4.0_" + n.Version.ToString()+ " __" + String.concat " " [| for b in n.GetPublicKeyToken() -> sprintf " %02x " b |])
184
- printfn " searching GAC: %s " verdir
185
-
186
- if Directory.Exists( verdir) then
187
- let trialPath = Path.Combine( verdir, qual)
188
- printfn " searching GAC: %s " trialPath
189
- if FileSystem.SafeExists( trialPath) then
190
- success trialPath
182
+ match n.Version, n.GetPublicKeyToken() with
183
+ | null , _ | _, null ->
184
+ let options =
185
+ [ for gacdir in Directory.EnumerateDirectories( gac) do
186
+ let assdir = Path.Combine( gacdir, n.Name)
187
+ if Directory.Exists( assdir) then
188
+ for tdir in Directory.EnumerateDirectories( assdir) do
189
+ let trialPath = Path.Combine( tdir, qual)
190
+ if FileSystem.SafeExists( trialPath) then
191
+ yield trialPath ]
192
+ //printfn "sorting GAC paths: %A" options
193
+ options
194
+ |> List.sort // puts latest version last
195
+ |> List.tryLast
196
+ |> function None -> () | Some p -> success p
197
+
198
+ | v, tok ->
199
+ for gacdir in Directory.EnumerateDirectories( gac) do
200
+ //printfn "searching GAC directory: %s" gacdir
201
+ let assdir = Path.Combine( gacdir, n.Name)
202
+ if Directory.Exists( assdir) then
203
+ //printfn "searching GAC directory: %s" assdir
204
+
205
+ let tokText = String.concat " " [| for b in tok -> sprintf " %02x " b |]
206
+ let verdir = Path.Combine( assdir, " v4.0_" + v.ToString()+ " __" + tokText)
207
+ //printfn "searching GAC directory: %s" verdir
208
+
209
+ if Directory.Exists( verdir) then
210
+ let trialPath = Path.Combine( verdir, qual)
211
+ //printfn "searching GAC: %s" trialPath
212
+ if FileSystem.SafeExists( trialPath) then
213
+ success trialPath
191
214
with e -> logWarning " SR001" ( e.ToString())
215
+ #endif
192
216
193
-
194
- //if not found then
195
- // let ass = try Some (Assembly.Load(r)) with _ -> None
196
- // match ass with
197
- // | Some ass -> success ass.Location
198
- // | None -> ()
199
217
results.ToArray() }
200
218
201
219
let GetDefaultResolver ( msbuildEnabled : bool , msbuildVersion : string option ) =
@@ -244,10 +262,10 @@ let fscoreDir =
244
262
let resolve s =
245
263
SimulatedMSBuildResolver.Resolve( ResolutionEnvironment.CompileTimeLike,[| for a in s -> ( a, " " ) |], " v4.5.1" , [ SimulatedMSBuildResolver.DotNetFrameworkReferenceAssembliesRootDirectory + @" \v4.5.1" ], " " , " " , fscoreDir,[],__ SOURCE_ DIRECTORY__, ignore, ( fun _ _ -> ()), ( fun _ _ -> ()))
246
264
247
- // Resolve partial name
265
+ // Resolve partial name to something on search path
248
266
resolve [ " FSharp.Core" ]
249
267
250
- // Resolve partial name
268
+ // Resolve DLL name to something on search path
251
269
resolve [ " FSharp.Core.dll" ]
252
270
253
271
// Resolve from reference assemblies
@@ -261,5 +279,11 @@ resolve [ "FSharp.Core, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b03f5f7
261
279
262
280
// Resolve from GAC:
263
281
resolve [ " EventViewer, Version=6.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" ]
282
+
283
+ // Resolve from GAC:
284
+ resolve [ " EventViewer" ]
285
+
286
+ resolve [ " Microsoft.SharePoint.Client, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" ]
287
+ resolve [ " Microsoft.SharePoint.Client, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" ]
264
288
#endif
265
289
0 commit comments