Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update getting started on macos #1560

Merged
merged 4 commits into from
Mar 7, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update for new VS code extension behavior.
  • Loading branch information
BillWagner committed Mar 7, 2017
commit cfdcc67f4cd5c9520636a66a8ee70128cb278847
104 changes: 37 additions & 67 deletions docs/core/tutorials/using-on-macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,33 @@ tests for that library project, and a console application that makes
use of the library.

Let's start by creating those folders. In the terminal, create a 'golden'
directory.
Create *app* and *library* directories for the application and the class
library, respectively. Create a *test-library* directory. You can do this either using the terminal
in VS code, or by clicking on the parent folder in VS Code and selecting the
"New Folder" icon.

In VS Code, open the *golden* directory. This directory is the root of your solution.

At this point, your directory tree should look like this:
directory. In VS Code, open the *golden* directory. This directory is the root of your solution. Run the `dotnet new` command to create a new solution:

```
/golden
|__/app
|__/library
|__/test-library
dotnet new sln
```

### Writing the library
This command creates a *golden.sln* file for the entire solution.

Your next task is to create the library. In the terminal window
(either the embedded terminal in VS code, or another terminal),
cd to *golden/library* and type the command `dotnet new classlib`.
cd to *golden/* and type the command:

```
dotnet new classlib library
```

This creates a library project, with two files: *library.csproj* and
*Class1.cs*.
*Class1.cs* in the *library* directory. You want that library project
included in your solution. Run the `dotnet sln` command to add the newly
created `library.csproj` project to the solution:

*library.csproj* contains the following information:
```
dotnet sln add library/library.csproj
```

Let's examine the project that you've created. The *library.csproj* file
contains the following information:

```xml
<Project Sdk="Microsoft.NET.Sdk">
Expand All @@ -87,10 +88,10 @@ This creates a library project, with two files: *library.csproj* and
This library project will make use of JSON representation of objects, so you'll want to
add a reference to the `Newtonsoft.Json` NuGet package. The `dotnet add` command
adds new items to a project. To add a reference to a NuGet package, you use the
`package` command and specify the name of the package:
`package` command and specify the name of the package.

```
dotnet add package Newtonsoft.Json
dotnet add library package Newtonsoft.Json
```

This adds `Newtonsoft.Json` and its dependencies to the Library
Expand Down Expand Up @@ -143,14 +144,16 @@ You now have a built *library.dll* file under *golden/library/bin/Debug/netstand

### Writing the test project

Let's build a test project for this library that you've build. Change to the *test-library*
directory. Run `dotnet new xunit` to create a new test project.
Let's build a test project for this library that you've build. Change to the *golden*
directory. Run `dotnet new xunit -o test-library` to create a new test project.
You'll want to add this project to the solution as well by running
`dotnet sln add test-library/test-library.csproj`.

You'll need to add a dependency node for the library you wrote in the steps
above. The `dotnet add reference` command does that:

```
dotnet add ../library/library.csproj
dotnet add test-library/test-library.csproj reference library/library.csproj
```

Or, you can manually edit the test-library.csproj file and add the
Expand Down Expand Up @@ -186,21 +189,26 @@ namespace TestApp
}
```

Now, run `dotnet restore`, `dotnet build` and `dotnet test`.
Now, run `dotnet restore` and `dotnet build`. These commands will
recursively find all projects to restore dependencies and build them.
Finally, run `dotnet test test-library/test-library.csproj` to
run the tests.
The xUnit console test runner will run the one test, and report
that it is passing.

### Writing the console app

In your terminal, cd to the *golden/app* directory. Run `dotnet new console`
to create a new console application.
In your terminal run `dotnet new console -o app`
to create a new console application. This proejct is also
part of the solution, so run `dotnet sln add app/app.csproj`
to add the project to the solution.

Your console application depends on the library you built and tested
in the previous steps. You need to indicate that by running `dotnet add reference`
again:

```
dotnet add reference ../library/library.csproj
dotnet add app/app.csproj reference library/library.csproj
```

Run `dotnet restore` to restore all dependencies. Open `program.cs`
Expand All @@ -218,7 +226,9 @@ using Library;
```

Then, run `dotnet build`. That creates the assemblies, and you
can type `dotnet run` to run the executable.
can type `dotnet run -p app/app.csproj` to run the executable.
The `-p` argument to `dotnet run` specifies the project for the
main application.

### Debugging your application

Expand All @@ -235,46 +245,6 @@ debugger tab (see figure).

![VS Code Debugger](./media/using-on-macos/vscodedebugger.png)


When you start the debugger, VS Code will instruct you to configure
the debugger. When you do, it creates a `.vscode` directory
with two files: `tasks.json` and `launch.json`. These two files control the debugger
configuration. In most projects, this directory is not included in source control.
It is included in the sample associated with this walk through so you can see
the edits you need to make.

Your solution contains multiple projects, so you'll want to modify each of these files
to perform the correct commands. First, open `tasks.json`. The default build task
runs `dotnet build` in the workspace source directory. Instead, you want to run it in
the `src/app` directory. You need to add a `options` node to set the current
working directory to that:

```json
"options": {
"cwd": "${workspaceRoot}/app"
}
```

Next, you'll need to open `launch.json` and update the program path. You'll see a
node under "configurations" that describes the program. You'll see:

```json
"program": "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>",
```

You'll change this to:

```json
"program": "${workspaceRoot}/app/bin/Debug/netcoreapp1.0/app.dll",
```

You'll also see another `cwd` option with the value `${workspaceRoot}`. Change
that to:

```json
"cwd": "${workspaceRoot}/app"
```

Set a breakpoint at the `WriteLine` statement in `Main`. You do this
by pressing the `F9` key, or by clicking the mouse in the left margin
on the line you want the breakpoint.
Expand Down
32 changes: 3 additions & 29 deletions samples/core/getting-started/golden/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,16 @@
"preLaunchTask": "build",
"program": "${workspaceRoot}/app/bin/Debug/netcoreapp1.0/app.dll",
"args": [],
"cwd": "${workspaceRoot}/app",
"stopAtEntry": false,
"externalConsole": false
},
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>",
"args": [],
"cwd": "${workspaceRoot}",
"externalConsole": false,
"stopAtEntry": false,
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": 0
"processId": "${command.pickProcess}"
}
]
}
10 changes: 3 additions & 7 deletions samples/core/getting-started/golden/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"options": {
"cwd": "${workspaceRoot}/app"
},
"tasks": [
{
"taskName": "build",
"args": [ ],
"args": [
"${workspaceRoot}/app/app.csproj"
],
"isBuildCommand": true,
"showOutput": "silent",
"problemMatcher": "$msCompile"
}
]
Expand Down
54 changes: 54 additions & 0 deletions samples/core/getting-started/golden/golden.sln
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
<<<<<<< HEAD

=======

>>>>>>> Update for new VS code extension behavior.
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
<<<<<<< HEAD
=======
Project("{13B669BE-BB05-4DDF-9536-439F39A36129}") = "library", "library\library.csproj", "{A546901F-B028-4FBB-82AE-E9B623687A0C}"
EndProject
Project("{13B669BE-BB05-4DDF-9536-439F39A36129}") = "test-library", "test-library\test-library.csproj", "{C424DA1F-BFC4-4991-B1D4-A0D6D7BBD60F}"
EndProject
Project("{13B669BE-BB05-4DDF-9536-439F39A36129}") = "app", "app\app.csproj", "{C3496C68-A579-4717-8ED6-95A17FF0192E}"
EndProject
>>>>>>> Update for new VS code extension behavior.
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,4 +28,45 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
<<<<<<< HEAD
=======
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A546901F-B028-4FBB-82AE-E9B623687A0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A546901F-B028-4FBB-82AE-E9B623687A0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A546901F-B028-4FBB-82AE-E9B623687A0C}.Debug|x64.ActiveCfg = Debug|x64
{A546901F-B028-4FBB-82AE-E9B623687A0C}.Debug|x64.Build.0 = Debug|x64
{A546901F-B028-4FBB-82AE-E9B623687A0C}.Debug|x86.ActiveCfg = Debug|x86
{A546901F-B028-4FBB-82AE-E9B623687A0C}.Debug|x86.Build.0 = Debug|x86
{A546901F-B028-4FBB-82AE-E9B623687A0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A546901F-B028-4FBB-82AE-E9B623687A0C}.Release|Any CPU.Build.0 = Release|Any CPU
{A546901F-B028-4FBB-82AE-E9B623687A0C}.Release|x64.ActiveCfg = Release|x64
{A546901F-B028-4FBB-82AE-E9B623687A0C}.Release|x64.Build.0 = Release|x64
{A546901F-B028-4FBB-82AE-E9B623687A0C}.Release|x86.ActiveCfg = Release|x86
{A546901F-B028-4FBB-82AE-E9B623687A0C}.Release|x86.Build.0 = Release|x86
{C424DA1F-BFC4-4991-B1D4-A0D6D7BBD60F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C424DA1F-BFC4-4991-B1D4-A0D6D7BBD60F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C424DA1F-BFC4-4991-B1D4-A0D6D7BBD60F}.Debug|x64.ActiveCfg = Debug|x64
{C424DA1F-BFC4-4991-B1D4-A0D6D7BBD60F}.Debug|x64.Build.0 = Debug|x64
{C424DA1F-BFC4-4991-B1D4-A0D6D7BBD60F}.Debug|x86.ActiveCfg = Debug|x86
{C424DA1F-BFC4-4991-B1D4-A0D6D7BBD60F}.Debug|x86.Build.0 = Debug|x86
{C424DA1F-BFC4-4991-B1D4-A0D6D7BBD60F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C424DA1F-BFC4-4991-B1D4-A0D6D7BBD60F}.Release|Any CPU.Build.0 = Release|Any CPU
{C424DA1F-BFC4-4991-B1D4-A0D6D7BBD60F}.Release|x64.ActiveCfg = Release|x64
{C424DA1F-BFC4-4991-B1D4-A0D6D7BBD60F}.Release|x64.Build.0 = Release|x64
{C424DA1F-BFC4-4991-B1D4-A0D6D7BBD60F}.Release|x86.ActiveCfg = Release|x86
{C424DA1F-BFC4-4991-B1D4-A0D6D7BBD60F}.Release|x86.Build.0 = Release|x86
{C3496C68-A579-4717-8ED6-95A17FF0192E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C3496C68-A579-4717-8ED6-95A17FF0192E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3496C68-A579-4717-8ED6-95A17FF0192E}.Debug|x64.ActiveCfg = Debug|x64
{C3496C68-A579-4717-8ED6-95A17FF0192E}.Debug|x64.Build.0 = Debug|x64
{C3496C68-A579-4717-8ED6-95A17FF0192E}.Debug|x86.ActiveCfg = Debug|x86
{C3496C68-A579-4717-8ED6-95A17FF0192E}.Debug|x86.Build.0 = Debug|x86
{C3496C68-A579-4717-8ED6-95A17FF0192E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C3496C68-A579-4717-8ED6-95A17FF0192E}.Release|Any CPU.Build.0 = Release|Any CPU
{C3496C68-A579-4717-8ED6-95A17FF0192E}.Release|x64.ActiveCfg = Release|x64
{C3496C68-A579-4717-8ED6-95A17FF0192E}.Release|x64.Build.0 = Release|x64
{C3496C68-A579-4717-8ED6-95A17FF0192E}.Release|x86.ActiveCfg = Release|x86
{C3496C68-A579-4717-8ED6-95A17FF0192E}.Release|x86.Build.0 = Release|x86
EndGlobalSection
>>>>>>> Update for new VS code extension behavior.
EndGlobal