-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started
Install the .NET Core SDK preview1 from http://dot.net.
You can install from packages or from binaries.
If you install from binaries, just unzip and add the directory to PATH
After you install the tools, check if the .NET SDK works, by running:
dotnet --info
The expected output (and exit code zero) is:
.NET Command Line Tools (1.0.0-preview1-002702)
Product Information:
Version: 1.0.0-preview1-002702
Commit Sha: 6cde21225e
Runtime Environment:
OS Name: Windows
OS Version: 10.0.10586
OS Platform: Windows
RID: win10-x64
The simplest way to create a new F# console app for .NET Core is to use the dotnet new
command.
NOTE The mkdir
and cd
are needed because dotnet new
creates the project in the current directory.
mkdir helloworld
cd helloworld
dotnet new --lang f#
If everything is okay, you should see:
Created new F# project in c:\helloworld.
The dotnet new --lang f#
command creates the following in the current directory:
-
Program.fs
the F# source file with main -
project.json
the project file -
NuGet.Config
list of Nuget feeds.
The project depends on the .NET Standard Library and FSharp.Core library. Before you can run the app, you need to restore all of the project's dependencies.
To download these dependencies, run:
dotnet restore
The expected output is:
log : Restoring packages for c:\helloworld\project.json...
info : GET https://dotnet.myget.org/F/dotnet-core/api/v3/flatcontainer/microsoft.netcore.platforms/index.json
...
verbose nuget
...
info : NotFound https://www.myget.org/F/fsharp-daily/api/v3/flatcontainer/microsoft.netcore.platforms/index.json 108ms
info : Committing restore...
log : Restore completed in 34962ms.
NuGet Config files used:
c:\helloworld\NuGet.Config
C:\Users\user\AppData\Roaming\NuGet\NuGet.Config
Feeds used:
https://dotnet.myget.org/F/dotnet-cli/api/v3/index.json
https://api.nuget.org/v3/index.json
https://www.myget.org/F/fsharp-daily/api/v3/index.json
This command will create in the project directory:
project.lock.json
The project.lock.json
contains the list of all packages/version needed by the project
Think about it as an build temp file
To build and run the console app, use the dotnet run
command.
The dotnet run
command builds the project, and if successful, runs it with the command line arguments passed to dotnet run
.
dotnet run arg1 arg2
If everything it's okay, the output should be:
Compiling helloworld (.NETStandard,Version=v1.5) will be compiled because expected outputs are missing
Compilation succeeded.
0 Warning(s)
0 Error(s)
Time elapsed 00:00:07.1147471
Hello World!
[|"arg1"; "arg2"|]
The first part is the build output. The second part the console app execution output.