mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-01-28 10:44:14 +01:00
Add item for page 179
This commit is contained in:
parent
439ee265dc
commit
40752d3a9b
131
docs/command-lines.md
Normal file
131
docs/command-lines.md
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
**Command-Lines**
|
||||
|
||||
To make it easier to enter commands at the prompt, this page lists all commands as a single line that can be copied and pasted.
|
||||
|
||||
- [Chapter 1 - Hello, C#! Welcome, .NET!](#chapter-1---hello-c-welcome-net)
|
||||
- [Page 9 - Managing Visual Studio Code extensions at the command line](#page-9---managing-visual-studio-code-extensions-at-the-command-line)
|
||||
- [Page 14 - Listing and removing versions of .NET](#page-14---listing-and-removing-versions-of-net)
|
||||
- [Page 27 - Writing code using Visual Studio Code](#page-27---writing-code-using-visual-studio-code)
|
||||
- [Page 29 - Compiling and running code using the dotnet CLI](#page-29---compiling-and-running-code-using-the-dotnet-cli)
|
||||
- [Page 36 - Cloning the book solution code repository](#page-36---cloning-the-book-solution-code-repository)
|
||||
- [Page 36 - Getting help for the dotnet tool](#page-36---getting-help-for-the-dotnet-tool)
|
||||
- [Chapter 2 - Speaking C#](#chapter-2---speaking-c)
|
||||
- [Page 51 - How to output the SDK version](#page-51---how-to-output-the-sdk-version)
|
||||
- [Chapter 3 -](#chapter-3--)
|
||||
- [Page 176 - Configuring trace listeners](#page-176---configuring-trace-listeners)
|
||||
- [Page 178 - Adding packages to a project in Visual Studio Code](#page-178---adding-packages-to-a-project-in-visual-studio-code)
|
||||
|
||||
# Chapter 1 - Hello, C#! Welcome, .NET!
|
||||
|
||||
## Page 9 - Managing Visual Studio Code extensions at the command line
|
||||
|
||||
```
|
||||
code --install-extension ms-dotnettools.csharp
|
||||
```
|
||||
|
||||
## Page 14 - Listing and removing versions of .NET
|
||||
|
||||
Listing all installed .NET SDKS:
|
||||
```
|
||||
dotnet --list-sdks
|
||||
```
|
||||
|
||||
Listing all installed .NET runtimes:
|
||||
```
|
||||
dotnet --list-runtimes
|
||||
```
|
||||
|
||||
Details of all .NET installations:
|
||||
```
|
||||
dotnet --info
|
||||
```
|
||||
|
||||
Remove all but the latest .NET SDK preview:
|
||||
```
|
||||
dotnet-core-uninstall remove --all-previews-but-latest --sdk
|
||||
```
|
||||
|
||||
## Page 27 - Writing code using Visual Studio Code
|
||||
|
||||
Creating a new **Console App** project:
|
||||
```
|
||||
dotnet new console
|
||||
```
|
||||
|
||||
Creating a new **Console App** project that targets an older version:
|
||||
```
|
||||
dotnet new console -f net6.0
|
||||
```
|
||||
|
||||
Creating a new **Console App** project that in a named subfolder:
|
||||
```
|
||||
dotnet new console -o HelloCS
|
||||
```
|
||||
|
||||
## Page 29 - Compiling and running code using the dotnet CLI
|
||||
```
|
||||
dotnet run
|
||||
```
|
||||
|
||||
## Page 36 - Cloning the book solution code repository
|
||||
|
||||
```
|
||||
git clone https://github.com/markjprice/cs11dotnet7.git
|
||||
```
|
||||
|
||||
## Page 36 - Getting help for the dotnet tool
|
||||
|
||||
Getting help for a `dotnet` command like `new`:
|
||||
```
|
||||
dotnet help new
|
||||
```
|
||||
|
||||
Getting help for a project template like `console`:
|
||||
```
|
||||
dotnet new console -h
|
||||
```
|
||||
|
||||
# Chapter 2 - Speaking C#
|
||||
|
||||
## Page 51 - How to output the SDK version
|
||||
|
||||
```
|
||||
dotnet --version
|
||||
```
|
||||
|
||||
# Chapter 3 -
|
||||
|
||||
## Page 176 - Configuring trace listeners
|
||||
|
||||
Running a project with its release configuration:
|
||||
```
|
||||
dotnet run --configuration Release
|
||||
```
|
||||
|
||||
Running a project with its debug configuration:
|
||||
```
|
||||
dotnet run --configuration Debug
|
||||
```
|
||||
|
||||
## Page 178 - Adding packages to a project in Visual Studio Code
|
||||
|
||||
Adding the `Microsoft.Extensions.Configuration` package:
|
||||
```
|
||||
dotnet add package Microsoft.Extensions.Configuration
|
||||
```
|
||||
|
||||
Adding the `Microsoft.Extensions.Configuration.Binder` package:
|
||||
```
|
||||
dotnet add package Microsoft.Extensions.Configuration.Binder
|
||||
```
|
||||
|
||||
Adding the `Microsoft.Extensions.Configuration.FileExtensions` package:
|
||||
```
|
||||
dotnet add package Microsoft.Extensions.Configuration.FileExtensions
|
||||
```
|
||||
|
||||
Adding the `Microsoft.Extensions.Configuration.Json` package:
|
||||
```
|
||||
dotnet add package Microsoft.Extensions.Configuration.Json
|
||||
```
|
||||
|
||||
|
|
@ -4,6 +4,6 @@ If you find any mistakes in the seventh edition, *C# 11 and .NET 7 - Modern Cros
|
|||
|
||||
[**Errata** (18 items)](errata.md): Typos, tool user interface changes, or mistakes in code that would cause a compilation error that prevents a successful build.
|
||||
|
||||
[**Improvements** (2 items)](improvements.md): Changes to text or code that would improve the content. These are optional.
|
||||
[**Improvements** (3 items)](improvements.md): Changes to text or code that would improve the content. These are optional.
|
||||
|
||||
All errata and improvements will be included in the 8th edition planned for publishing in November 2023. To be included they must be submitted by mid-September 2023.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
**Improvements** (2 items)
|
||||
**Improvements** (3 items)
|
||||
|
||||
If you have suggestions for improvements, then please [raise an issue in this repository](https://github.com/markjprice/cs11dotnet7/issues) or email me at markjprice (at) gmail.com.
|
||||
|
||||
- [Page 153 - Writing a function that returns a value](#page-153---writing-a-function-that-returns-a-value)
|
||||
- [Page 179 - Reviewing project packages](#page-179---reviewing-project-packages)
|
||||
- [Page 453 - Scaffolding models using an existing database](#page-453---scaffolding-models-using-an-existing-database)
|
||||
|
||||
# Page 153 - Writing a function that returns a value
|
||||
|
|
@ -15,6 +16,38 @@ Add the following statement near the top of the code file before doing any writi
|
|||
Console.OutputEncoding = System.Text.Encoding.UTF8;
|
||||
```
|
||||
|
||||
# Page 179 - Reviewing project packages
|
||||
|
||||
In Step 1, the instruct the reader to add references to four packages, as shown in the following markup:
|
||||
```xml
|
||||
<ItemGroup>
|
||||
<PackageReference
|
||||
Include="Microsoft.Extensions.Configuration"
|
||||
Version="7.0.0" />
|
||||
<PackageReference
|
||||
Include="Microsoft.Extensions.Configuration.Binder"
|
||||
Version="7.0.0" />
|
||||
<PackageReference
|
||||
Include="Microsoft.Extensions.Configuration.FileExtensions"
|
||||
Version="7.0.0" />
|
||||
<PackageReference
|
||||
Include="Microsoft.Extensions.Configuration.Json"
|
||||
Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
```
|
||||
|
||||
Due to transitive dependencies, you only actually need to explicitly reference two of the packages, as shown in the following markup:
|
||||
```xml
|
||||
<ItemGroup>
|
||||
<PackageReference
|
||||
Include="Microsoft.Extensions.Configuration.Binder"
|
||||
Version="7.0.0" />
|
||||
<PackageReference
|
||||
Include="Microsoft.Extensions.Configuration.Json"
|
||||
Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
```
|
||||
|
||||
# Page 453 - Scaffolding models using an existing database
|
||||
|
||||
In Step 2, I show text that must be entered as a single line at the command-line, as shown in the following command formatted as in the print book:
|
||||
|
|
|
|||
Loading…
Reference in a new issue