diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index db23964cc6..4c6ba0f33f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -28,7 +28,12 @@ } }, "remoteEnv": { - "TARGET": "net9.0" + "TARGET": "net9.0", + "DOTNET_ROOT": "${containerWorkspaceFolder}/.dotnet", + "PATH": "${containerWorkspaceFolder}/.dotnet:${containerEnv:PATH}" }, - "postCreateCommand": [ "dotnet", "build", "FSharp.Compiler.Service.sln"] + "postCreateCommand": [ + "bash", "-c", + "./eng/common/dotnet.sh && dotnet build FSharp.Compiler.Service.sln" + ] } diff --git a/DEVGUIDE.md b/DEVGUIDE.md index c551c90af2..e1630ce6c2 100644 --- a/DEVGUIDE.md +++ b/DEVGUIDE.md @@ -102,6 +102,49 @@ Running tests: You can then open `FSharp.sln` in your editor of choice. +## Working with non-released .NET SDKs + +This repository may require a non-released version of the .NET SDK, as specified in the `global.json` file. When the required SDK version is not publicly available through normal channels, you may encounter an error when running `dotnet build` directly: + +``` +The .NET SDK could not be found, please run ./eng/common/dotnet.sh. +``` + +### Setting up the correct SDK + +Before using plain `dotnet build` commands, you need to install the required SDK version locally: + +**On Linux/macOS:** +```shell +./eng/common/dotnet.sh +``` + +**On Windows:** +```shell +.\eng\common\dotnet.cmd +``` + +This downloads and installs the correct SDK version to a local `.dotnet` directory in the repository root. + +### Using dotnet commands with the local SDK + +After running the setup script once to install the SDK, you can use regular `dotnet` commands normally: + +1. **One-time SDK installation**: + ```shell + # Linux/macOS + ./eng/common/dotnet.sh + + # Windows + .\eng\common\dotnet.cmd + ``` + +2. **Regular dotnet commands** (after SDK installation): + ```shell + dotnet build FSharp.Compiler.Service.sln + dotnet test tests/FSharp.Compiler.Service.Tests/ + ``` + ## Testing from the command line You can find all test options as separate flags. For example `build -testAll`: