Skip to content

Commit 40b83b0

Browse files
authored
Add workshop materials (dotnetgirls#1)
1 parent eee8a45 commit 40b83b0

File tree

308 files changed

+6634
-1588
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

308 files changed

+6634
-1588
lines changed

.github/workflows/publish-gh-pages.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: Publish Blazor App to GitHub Pages
22

3-
on: [ push, workflow_dispatch ]
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- 'src/MyPortfolio/**'
48

59
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
610
permissions:
@@ -31,7 +35,7 @@ jobs:
3135
# - name: Set basepath on index.html
3236
# shell: pwsh
3337
# run: |
34-
# $filepath = "./src/BlazorApp/wwwroot/index.html"
38+
# $filepath = "./src/MyPortfolio/wwwroot/index.html"
3539
# $repository = "${{ github.repository }}" -replace "${{ github.repository_owner }}", ""
3640

3741
# $html = Get-Content -Path $filepath
@@ -40,7 +44,7 @@ jobs:
4044
# - name: Set basepath on JSON objects
4145
# shell: pwsh
4246
# run: |
43-
# $filepath = "./src/BlazorApp/wwwroot/sample-data"
47+
# $filepath = "./src/MyPortfolio/wwwroot/sample-data"
4448
# $repository = "${{ github.repository }}" -replace "${{ github.repository_owner }}", ""
4549

4650
# Get-ChildItem -Path $filepath -Filter "*.json" | ForEach-Object {
@@ -51,22 +55,22 @@ jobs:
5155
- name: Restore NuGet packages
5256
shell: bash
5357
run: |
54-
dotnet restore .
58+
dotnet restore ./src
5559
5660
- name: Build solution
5761
shell: bash
5862
run: |
59-
dotnet build .
63+
dotnet build ./src -c Release
6064
6165
- name: Test solution
6266
shell: bash
6367
run: |
64-
dotnet test . -c Release
68+
dotnet test ./src -c Release
6569
6670
- name: Publish artifact
6771
shell: bash
6872
run: |
69-
dotnet publish src/BlazorApp -c Release -o published
73+
dotnet publish ./src/MyPortfolio -c Release -o published
7074
7175
- name: Upload artifact for web
7276
uses: actions/upload-pages-artifact@v1

MyPortfolio.sln

Lines changed: 0 additions & 27 deletions
This file was deleted.

README.md

Lines changed: 28 additions & 364 deletions
Large diffs are not rendered by default.

docs/00-setup.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Prepare your development environment
2+
3+
In this workshop, we will be using [GitHub Codespaces](https://docs.github.com/codespaces/overview).
4+
5+
What is GitHub Codespaces? It's a development environment that's hosted in the cloud. It allows you to develop entirely in the cloud, without needing to install anything on your local machine. It's like Visual Studio Code, but in the cloud.
6+
7+
With GitHub Codespaces, you can create a new development environment in seconds, and start coding right away. You can also share your development environment with others, and collaborate in real-time.
8+
9+
OK. Let's get started!
10+
11+
## Step 1: Fork the GitHub repository
12+
13+
1. First, you need to fork this repository to your GitHub account. To do that, click the "Fork" button at the top-right corner of this page.
14+
15+
![Button to fork](./images/00-setup-01.png)
16+
17+
1. You will see the screen below. Select your GitHub account, and click the "Create fork" button.
18+
19+
![Create fork](./images/00-setup-02.png)
20+
21+
1. After forking the repository, you will be redirected to your forked repository.
22+
23+
![Forked repository](./images/00-setup-03.png)
24+
25+
You have forked the repository to your GitHub account. Now, you can start coding in GitHub Codespaces.
26+
27+
## Step 2: Open the repository in GitHub Codespaces
28+
29+
1. To open the repository in GitHub Codespaces, click the "Code" button at the top-right corner of the repository, and click the "Create codespace on main" button.
30+
31+
![Button to create a new codespace](./images/00-setup-04.png)
32+
33+
1. Wait for a few minutes. GitHub initialises the new codespace instance for you. Depending on your network status, it might take 5-10 minutes.
34+
35+
![Initialising a new codespace](./images/00-setup-05.png)
36+
37+
1. Your codespace instance is ready when you see the screen below.
38+
39+
![Codespace workspace](./images/00-setup-06.png)
40+
41+
1. In the terminal, enter the following commands to see whether your codespace is ready for app development.
42+
43+
```bash
44+
dotnet --list-sdks
45+
```
46+
47+
1. You should see the .NET SDK version `6.x`, `7.x` and `8.x` like below.
48+
49+
```bash
50+
6.0.420 [/usr/share/dotnet/sdk]
51+
7.0.407 [/usr/share/dotnet/sdk]
52+
8.0.202 [/usr/share/dotnet/sdk]
53+
```
54+
55+
---
56+
57+
Congratulations! You have created a new codespace instance. Now, you can start coding in the cloud.
58+
59+
:point_right: [Step 1: Create a new Blazor WebAssembly application](./01-blazor-new.md)

docs/01-blazor-new.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Create a new Blazor WebAssembly application
2+
3+
In this step, you will create a new [Blazor WebAssembly](https://learn.microsoft.com/aspnet/core/blazor/hosting-models#blazor-webassembly) application using the `dotnet` command-line interface (CLI).
4+
5+
With Blazor WebAssembly, you build a web application purely running on a web browser. It's a modern single-page application (SPA) framework that runs on WebAssembly. It's a new way to build interactive client-side web UI with .NET.
6+
7+
![Blazor WebAssembly](https://learn.microsoft.com/aspnet/core/blazor/hosting-models/_static/blazor-webassembly.png)
8+
9+
👉 Image source: [Microsoft](https://learn.microsoft.com/aspnet/core/blazor/hosting-models#blazor-webassembly)
10+
11+
Generally speaking, web frontend UI applications rely on JavaScript for user interactions. If you don't know JavaScript, you have to learn it first to build an application. However, if you are a new starter building a web frontend UI application and don't know where to start, this Blazor WebAssembly is a good starting point for you because you only need to know C# and .NET for building both frontend and backend applications.
12+
13+
OK. Let's get started!
14+
15+
## Step 1: Create a new Blazor WebAssembly application
16+
17+
1. In the terminal, enter the following commands to setup the workshop folder. Remember that `$CODESPACE_VSCODE_FOLDER` is the root directory of your codespace workspace.
18+
19+
```bash
20+
cd $CODESPACE_VSCODE_FOLDER
21+
mkdir workshop
22+
cd workshop
23+
```
24+
25+
1. Enter the following command to create a new Blazor WebAssembly project.
26+
27+
```bash
28+
dotnet new blazorwasm -n MyPortfolio
29+
```
30+
31+
1. Enter the following commands to create a solution file and add the Blazor WebAssembly project to the solution.
32+
33+
```bash
34+
dotnet new sln -n MyPortfolio
35+
dotnet sln add MyPortfolio
36+
```
37+
38+
## Step 2: Build and run the Blazor WebAssembly application
39+
40+
1. Make sure you're in the `workshop` directory.
41+
42+
```bash
43+
cd $CODESPACE_VSCODE_FOLDER/workshop
44+
```
45+
46+
1. Build your Blazor WebAssembly project to make sure everything is working fine.
47+
48+
```bash
49+
dotnet restore && dotnet build
50+
```
51+
52+
1. Run the Blazor WebAssembly project to see the default application.
53+
54+
```bash
55+
dotnet watch run --project MyPortfolio
56+
```
57+
58+
1. You should see the popup message like below. Click the "Open in Browser" button to open the default Blazor WebAssembly application in your browser.
59+
60+
![Blazor WebAssembly popup](./images/01-blazor-new-01.png)
61+
62+
The screenshot above shows the port number of `5033`, but it might be different from yours.
63+
64+
1. The default Blazor WebAssembly application is open, and should look like below.
65+
66+
![Blazor WebAssembly default application](./images/01-blazor-new-02.png)
67+
68+
The web application's URL should look like `https://{{your-github-codespace-name}}-5033.app.github.dev`, instead of `https://localhost:5033`, where `5033` is your port number, which might be different from yours.
69+
70+
1. Stop the running application by pressing `Ctrl + C` in the terminal.
71+
72+
---
73+
74+
Congratulations! You have created a new Blazor WebAssembly application. Let's add some contents by creating a new component in the next step.
75+
76+
:point_right: [Step 2: Create a Home component](./02-home-component.md)

0 commit comments

Comments
 (0)