Source code of www.msdevshk.com
For development, we recommend Visual Studio Code.
Also recommended are the following extensions:
- C#
ms-vscode.csharp
- C# Extensions
jchannon.csharpextensions
- C# XML Documentation Comments
k--kato.docomment
- NuGet Package Manager
jmrog.vscode-nuget-package-manager
Other editors will work as well, but you'll miss out on the neat .vscode
setup to easily start and debug the website.
If you don't have it already, install the the .NET Core SDK for your platform. We currently target .NET Core 1.1.
The codebase is intentionally made to target ASP.NET Core, to allow development on both macOS as well as Windows. When you contribute, ensure that the code is cross platform.
Now you can open the project from Code by opening the root folder, and start from there. Follow any prompts to prepare your C# tooling, and restore packages as needed.
Alternatively, you can open a terminal and execute these commands to run the website on your local development machine:
dotnet restore
dotnet build
- Set the Development environment:
- Windows:
set ASPNETCORE_ENVIRONMENT=Development
- macOS:
export ASPNETCORE_ENVIRONMENT=Development
- Windows:
dotnet run
The website uses HTTPS to securely login users.
Use the shell files provided in Setup/macOS
:
cd Setup/macOS
chmod u+x create-cert.sh
- grant the current user execute permissions../create-cert.sh local.www.msdevshk.com PFXPASSWORD
- to create a self-signed CA certificate to be used as the certificate to host the website via HTTPS. Ensure to change the PFXPASSWORD parameter to a secure password.- Install the SSL certificate (.crt) file in the login keychain of macOS:
- In Finder, open the
MSDevsHK.Website/certs/cert.crt
certificate file. Keychain Access will open showing the cert in thelogin
keychain. - Double-click the
local.www.msdevshk.com
certificate, and expand the Trust section. - Set
Secure Sockets Layer (SSL)
toAlways Trust
. - Quit the Keychain Access application, you will be prompted for your administrator password to save the changes.
Enter your password and select
Update Settings
.
- In Finder, open the
A specific local domain is used to prevent malicious access of the development SSL certificate.
Use the bash script to manage the /etc/hosts
file entries:
cd Setup/macOS
chmod u+x manage-etc-hosts.sh
- grant the current user execute permissions.sudo ./manage-etc-hosts.sh add local.www.msdevshk.com
- add a new entry with administrator permissions.
To prevent that any sensitive information is stored in this repository, user secrets are used.
This is managed with the dotnet user-secrets -h
tool that needs to be executed from the website project directory.
cd MSDevsHK.Website
The password to open the PFX file made in the 'SSL Setup' section is stored as a secret.
dotnet user-secrets set Host:HttpsPfxPassword PFXPASSWORD
- Ensure to change the PFXPASSWORD parameter to the previously used secure password.