Skip to content

Commit 3eb293c

Browse files
authored
Merge pull request #240 from Numpsy/6to8
Change the 'Getting started writing an analyzer' docs to use .NET 8.0…
2 parents c046812 + 64a9826 commit 3eb293c

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

docs/content/Getting Started Writing.fsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ These class libraries expose a *value* of type [Analyzer<'TContext>](../referenc
1414
1515
## Create project
1616
17-
Create a new class library targeting `net6.0`
17+
Create a new class library targeting `net8.0`
1818
1919
```shell
20-
dotnet new classlib -lang F# -f net6.0 -n OptionValueAnalyzer
20+
dotnet new classlib -lang F# -f net8.0 -n OptionValueAnalyzer
2121
```
2222
2323
Note that the assembly name needs to contain `Analyzer` in the name in order for it to be picked up.
@@ -38,7 +38,7 @@ The `FSharp.Analyzers.SDK` takes a dependency on [FSharp.Compiler.Service](https
3838
It is considered a best practice to use the correct `FSharp.Core` version and not the implicit one from the SDK.
3939
4040
```xml
41-
<PackageReference Update="FSharp.Core" Version="7.0.400" />
41+
<PackageReference Update="FSharp.Core" Version="9.0.300" />
4242
```
4343
4444
## First analyzer
@@ -120,13 +120,13 @@ Simply run `dotnet pack --configuration Release` against the analyzer project to
120120
dotnet nuget push {NugetPackageFullPath} -s nuget.org -k {NugetApiKey}
121121
```
122122
123-
However, the story is different and slightly more complicated when your analyzer package has third-party dependencies also coming from nuget. Since the SDK dynamically loads the package assemblies (`.dll` files), the assemblies of the dependencies have to be right *next* to the main assembly of the analyzer. Using `dotnet pack` will **not** include these dependencies into the output Nuget package. More specifically, the `./lib/net6.0` directory of the nuget package must have all the required assemblies, also those from third-party packages. In order to package the analyzer properly with all the assemblies, you need to take the output you get from running:
123+
However, the story is different and slightly more complicated when your analyzer package has third-party dependencies also coming from nuget. Since the SDK dynamically loads the package assemblies (`.dll` files), the assemblies of the dependencies have to be right *next* to the main assembly of the analyzer. Using `dotnet pack` will **not** include these dependencies into the output Nuget package. More specifically, the `./lib/net8.0` directory of the nuget package must have all the required assemblies, also those from third-party packages. In order to package the analyzer properly with all the assemblies, you need to take the output you get from running:
124124
125125
```shell
126-
dotnet publish --configuration Release --framework net6.0
126+
dotnet publish --configuration Release --framework net8.0
127127
```
128128
129-
against the analyzer project and put every file from that output into the `./lib/net6.0` directory of the nuget package. This requires some manual work by unzipping the nuget package first (because it is just an archive), modifying the directories then zipping the package again. It can be done using a FAKE build target to automate the work:
129+
against the analyzer project and put every file from that output into the `./lib/net8.0` directory of the nuget package. This requires some manual work by unzipping the nuget package first (because it is just an archive), modifying the directories then zipping the package again. It can be done using a FAKE build target to automate the work:
130130
*)
131131

132132
// make ZipFile available
@@ -163,7 +163,7 @@ Target.create
163163
if exitCode <> 0 then
164164
failwith "dotnet pack failed"
165165
else
166-
match Shell.Exec("dotnet", "publish --configuration Release --framework net6.0", analyzerProject) with
166+
match Shell.Exec("dotnet", "publish --configuration Release --framework net8.0", analyzerProject) with
167167
| 0 ->
168168
let nupkg =
169169
System.IO.Directory.GetFiles(__SOURCE_DIRECTORY__ </> "dist")
@@ -173,15 +173,15 @@ Target.create
173173
let nugetParent = DirectoryInfo(nupkg).Parent.FullName
174174
let nugetFileName = Path.GetFileNameWithoutExtension(nupkg)
175175

176-
let publishPath = analyzerProject </> "bin" </> "Release" </> "net6.0" </> "publish"
176+
let publishPath = analyzerProject </> "bin" </> "Release" </> "net8.0" </> "publish"
177177
// Unzip the nuget
178178
ZipFile.ExtractToDirectory(nupkg, nugetParent </> nugetFileName)
179179
// delete the initial nuget package
180180
File.Delete nupkg
181-
// remove stuff from ./lib/net6.0
182-
Shell.deleteDir (nugetParent </> nugetFileName </> "lib" </> "net6.0")
183-
// move the output of publish folder into the ./lib/net6.0 directory
184-
Shell.copyDir (nugetParent </> nugetFileName </> "lib" </> "net6.0") publishPath (fun _ -> true)
181+
// remove stuff from ./lib/net8.0
182+
Shell.deleteDir (nugetParent </> nugetFileName </> "lib" </> "net8.0")
183+
// move the output of publish folder into the ./lib/net8.0 directory
184+
Shell.copyDir (nugetParent </> nugetFileName </> "lib" </> "net8.0") publishPath (fun _ -> true)
185185
// re-create the nuget package
186186
ZipFile.CreateFromDirectory(nugetParent </> nugetFileName, nupkg)
187187
// delete intermediate directory

0 commit comments

Comments
 (0)