|
This repository gathers Dafny code examples coming from various websites. It also includes several build scripts (bash scripts, batch files, Make scripts) for experimenting with Dafny on a Windows machine. |
Ada, Akka, C++, COBOL, Component Pascal, Dart, Deno, Docker, Flix, Go, GraalVM, Haskell, Kafka, Kotlin, LLVM, Modula-2, MySQL, Node.js, Rust, Scala 3, Spark, Spring, Standard ML, TruffleSqueak, WiX Toolset and Zig are other topics we are continuously monitoring.
Optionally one may also install the following software 2 :
- ConEmu 2023 (release notes)
- Dafny for Visual Studio Code 3.5 (release notes)
- Go 1.25 (release notes)
- Python 3.11 (changelog)
- Rust 1.91 (release notes)
- Temurin OpenJDK 17 LTS (release notes, bug fixes, Java 17 API)
- Visual Studio Code 1.106 (release notes)
☛ Installation policy
When possible we install software from a Zip archive rather than via a Windows installer. In our case we definedC:\opt\as the installation directory for optional software tools (in reference to the/opt/directory on Unix).
For instance our development environment looks as follows (December 2025) 3:
C:\opt\ConEmu\ ( 26 MB) C:\opt\dafny\ (135 MB) C:\opt\Git\ (393 MB) C:\opt\go\ (246 MB) C:\opt\jdk-temurin-17.0.17_10\ (302 MB) C:\opt\Python-3.11.1\ ( 77 MB) C:\opt\VSCode\ (381 MB) C:\Program Files\dotnet\sdk\6.0.428\ (329 MB) C:\Program Files\dotnet\sdk\9.0.307\ (381 MB) 4 %USERPROFILE%\.cargo\ (100 MB) %USERPROFILE%\.rustup\ (593 MB, installed toolchains and configuration options)
🔎 Git for Windows provides a Bash emulation used to run
gitfrom the command line (as well as over 250 Unix commands likeawk,diff,file,grep,more,mv,rmdir,sedandwc).
Directory structure ▴
This project is organized as follows:
bin\
docs\
examples\{README.md, Competition, Fibonacci, ..}
README.md
RESOURCES.md
setenv.bat
where
- directory
bin\contains utility tools. - directory
docs\contains Dafny related documents. - directory
examples\contains Dafny code examples (seeREADME.mdfile). - file
README.mdis the Markdown document for this page. - file
RESOURCES.mdis the Markdown document presenting external resources. - file
setenv.batis the batch command for setting up our environment.
Batch commands ▴
We execute command setenv once to setup our development environment; it makes external tools such as git.exe and sh.exe directly available from the command prompt.
> setenv Tool versions: cargo 1.19.1, rustc 1.19.1, dafny 4.11.0, javac 17.0.17, code 1.106.3, go 1.25.4, goimports v0.29.0, csc 4.14.0, git 2.52.0, diff 3.12, bash 5.2.37(1) > where git sh C:\opt\Git\bin\git.exe C:\opt\Git\mingw64\bin\git.exe C:\opt\Git\bin\sh.exe C:\opt\msys64\usr\bin\sh.exe C:\opt\Git\usr\bin\sh.exe
Command setenv-verbose also prints :
- the tool paths.
- the environment variables defined in the current session.
- the path associations (globally defined).
> setenv -verbose Tool versions: cargo 1.19.1, rustc 1.19.1, dafny 4.11.0, javac 17.0.17, code 1.106.3, go 1.25.4, goimports v0.29.0, csc 4.14.0, git 2.52.0, diff 3.12, bash 5.2.37(1) Tool paths: %USERPROFILE%\.cargo\bin\cargo.exe %USERPROFILE%\.cargo\bin\rustc.exe C:\opt\dafny\Dafny.exe C:\opt\jdk-temurin-17.0.17_10\bin\javac.exe C:\opt\VSCode\bin\code.cmd C:\opt\go\bin\go.exe %USERPROFILE%\go\bin\goimports.exe C:\opt\Git\bin\git.exe C:\opt\Git\usr\bin\diff.exe C:\opt\Git\bin\bash.exe Environment variables: "CARGO_HOME=%USERPROFILE%\.cargo" "DAFNY_HOME=C:\opt\dafny" "GIT_HOME=C:\opt\Git" "GOBIN=%USERPROFILE%\go\bin" "GOPATH=C:\Users\michelou\go" "GOROOT=C:\opt\Go" "JAVA_HOME=C:\opt\jdk-temurin-17.0.17_10" "VSCODE_HOME=C:\opt\VSCode" Path associations: G:\: => %USERPROFILE%\workspace-perso\dafny-examples
Footnotes ▴
[1] Missing .NET Framework ↩
-
Dafny requires the Microsoft .NET Framework 6.0 or newer to be installed; otherwise the following runtime error occurs :
> c:\opt\dafny\Dafny.exe run src\Fib.dfy Dafny program verifier finished with 3 verified, 0 errors It was not possible to find any compatible framework version The framework 'Microsoft.NETCore.App', version '6.0.0' was not found. - The following frameworks were found: 2.1.12 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 2.1.13 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 2.1.26 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 2.1.30 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 3.1.32 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] 5.0.17 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] You can resolve the problem by installing the specified framework and/or SDK. The specified framework can be found at: - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.0&arch=x64&rid=win10-x64
[2] Supported target languages ↩
- The current set of supported target languages is C#, Java, JavaScript, Python, Go and C++ (supported features by target language).
[3] Downloads ↩
- In our case we downloaded the following installation files (see section 1):
-
dafny-4.11.0-x64-windows-2019.zip ( 60 MB) dotnet-sdk-9.0.306-win-x64.exe (198 MB) go1.25.4.windows-amd64.zip ( 70 MB) OpenJDK17U-jdk_x64_windows_hotspot_17.0.17_10.zip (188 MB) PortableGit-2.52.0-64-bit.7z.exe ( 55 MB) python-3.11.1-amd64.exe ( 26 MB) rust-init.exe ( 8 MB) VSCode-win32-x64-1.106.3.zip (131 MB)
[4] .NET and MSBuild versioning ↩
-
The version pairing between .NET and MSBuild is listed in the Microsoft documentation (see Supported .NET version) :
SDK version MSBuild/MSVS version Ship Date Lifecycle 10.0.1xx 18.0 Nov 2025 Nov 2028 9.0.3xx 17.14 May 2025 Nov 2026 9.0.2xx 17.13 Feb 2025 May 2025 9.0.1xx 17.12 Nov 2024 May 2026 8.0.4xx 17.11 Aug 2024 Nov 2026 8.0.3xx 17.10 May 2024 Jan 2026
