This sample is part of the Getting started with .NET Core on macOS, using Visual Studio Code walkthrough. Please see that topic for detailed steps on the code for this sample.
This sample builds a program and an associated unit test assembly. You'll learn how to structure projects as part of a larger solution, and incorporate unit tests into your projects.
To build and run the sample, change to the src/library
directory and
type the following two commands:
dotnet restore
dotnet build
dotnet restore
(see note) installs all the dependencies for this sample into the current directory.
dotnet build
creates the output assembly (or assemblies).
Next, change to the app
directory and run those same
two commands again.
After that, type this command to run the executable:
dotnet run
dotnet run
runs the output executable.
To run the tests, change to the test-library
directory and
type the following three commands:
dotnet restore
dotnet build
dotnet test
dotnet test
runs all the configure tests
Note that you must run dotnet restore
(see note) in the src/library
directory before you can run
the tests. dotnet build
will follow the dependency and build both the library and unit
tests projects, but it will not restore NuGet packages.
This sample focuses on setting up and using Visual Studio Code as your development editor. The topic walks through all the setup and configuration steps for that environment.
[!INCLUDEDotNet Restore Note]