@@ -79,7 +79,8 @@ We use `GetProjectOptionsFromCommandLineArgs` to treat two files as a project:
79
79
80
80
let projectOptions =
81
81
let sysLib nm =
82
- if System.Environment.OSVersion.Platform = System.PlatformID.Win32NT then // file references only valid on Windows
82
+ if System.Environment.OSVersion.Platform = System.PlatformID.Win32NT then
83
+ // file references only valid on Windows
83
84
System.Environment.GetFolderPath( System.Environment.SpecialFolder.ProgramFilesX86) +
84
85
@" \Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\" + nm + " .dll"
85
86
else
@@ -88,7 +89,8 @@ let projectOptions =
88
89
sysDir ++ nm + " .dll"
89
90
90
91
let fsCore4300 () =
91
- if System.Environment.OSVersion.Platform = System.PlatformID.Win32NT then // file references only valid on Windows
92
+ if System.Environment.OSVersion.Platform = System.PlatformID.Win32NT then
93
+ // file references only valid on Windows
92
94
System.Environment.GetFolderPath( System.Environment.SpecialFolder.ProgramFilesX86) +
93
95
@" \Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\4.3.0.0\FSharp.Core.dll"
94
96
else
@@ -159,7 +161,7 @@ let rec allSymbolsInEntities (entities: IList<FSharpEntity>) =
159
161
let allSymbols = allSymbolsInEntities wholeProjectResults.AssemblySignature.Entities
160
162
(**
161
163
After checking the whole project, you can access the background results for individual files
162
- in the project. This will be fast and will not invlove any additional checking.
164
+ in the project. This will be fast and will not involve any additional checking.
163
165
*)
164
166
165
167
let backgroundParseResults1 , backgroundTypedParse1 =
@@ -307,8 +309,27 @@ correctly and then analyze each project in turn.
307
309
Cracking a project file
308
310
-----------------------------
309
311
310
- F# projects normally use the '.fsproj' project file format. You can get options corresponding to a project file
311
- using GetProjectOptionsFromProjectFile. In this example we get the project options for one of the
312
+ F# projects normally use the '.fsproj' project file format.
313
+ A project cracking facility is provided as a separate NuGet package:
314
+ FSharp.Compiler.Service.ProjectCracker. This NuGet package contains a
315
+ library FSharp.Compiler.Service.ProjectCracker.dll, which should be
316
+ referenced by your application directly, and an executable
317
+ FSharp.Compiler.Service.ProjectCrackerTool.exe, which should be copied
318
+ into the output folder of your application by the build process. This
319
+ can be accomplished by adding lines to your `.fsproj` file similar to:
320
+
321
+ <Target Name="AfterBuild">
322
+ <Copy SourceFiles="..\packages\FSharp.Compiler.Service.ProjectCracker\lib\net45\FSharp.Compiler.Service.ProjectCrackerTool.exe" DestinationFolder="$(OutputPath)" />
323
+ <Copy SourceFiles="..\packages\FSharp.Compiler.Service.ProjectCracker\lib\net45\FSharp.Compiler.Service.ProjectCrackerTool.exe.config" DestinationFolder="$(OutputPath)" />
324
+ </Target>
325
+
326
+ The reason for this split is so that the analysis of an F# project
327
+ file is performed out of process, in order that the necessary assembly
328
+ binding redirects can be applied without requiring the caller to
329
+ arrange this. In this way MSBuild versions from 4 up to 14 can be
330
+ accommodated transparently.
331
+
332
+ In this example we get the project options for one of the
312
333
project files in the F# Compiler Service project itself - you should also be able to use this technique
313
334
for any project that builds cleanly using the command line tools 'xbuild' or 'msbuild'.
314
335
0 commit comments