Skip to content

Local Development Environment Setup

Josh Bodner edited this page Jun 26, 2023 · 29 revisions

If you don't have Visual Studio 2022 installed, install it, making sure to include the following items during the install process:

  • ASP.Net and Web Development (under Web & Cloud)
  • Optional: Install Azure SDK (not currently required, but needed for file uploads)

If you already have Visual Studio installed, upgrade it to the latest version by running the Visual Studio Installer. Then, use that installer to "Modify" Visual Studio to make sure it includes the items above.

Install .NetCore 7.0 SDK. Note that this needs to be downloaded separately from Visual Studio.

Next, install EF Core by doing the following. (For more detailed instructions, please see: Installing EF Core.) If you're on a Mac, go down to the Mac Installation section below before continuing with these instructions.

  • Open Visual Studio->Open a project or solution and navigate to PuzzleServer.sln in your local repo
  • Open the Package Manager Console in Visual Studio with Tools->NuGet Package Manager->Package Manager Console.
  • In the Package Manager Console, run Install-Package Microsoft.EntityFrameworkCore.SqlServer
    • (This may fail with Install-Package: Project 'Default' is not found. If so, change the "Default project:" dropdown in the console to "Data". If this is blank, restart Visual Studio, ensuring you are opening the right solution)
    • (The current Version is 7.0.5; you can specify all this with Install-Package Microsoft.EntityFrameworkCore.SqlServer -Version 7.0.5)
  • In the Package Manager Console, run Update-Database.
    • (Advanced: You can find the connection string in ServerCore/appsettings.json if you don't want to use the default database installed by VS.)

Next, set up external authentication using the instructions at the External Authentication Setup wiki page

For more detailed instructions: Set up guide for deploying the database for the first time: https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/new-db

If you will be working with file uploads, ensure the Azure Storage Emulator is started. This can be launched by running "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator\azurite.exe".

Mac Installation

Visual Studio for Mac doesn't have the Nuget Package Manager console installed by default. You'll need to install the NuGet Package Management Extensions from the Visual Studio Extension manager.

The development environment also utilizes SQL Server, which isn't available for Mac. Instead, a Docker container with a SQL Server for Linux image will need to be installed, and the container will need to be running during development. Detailed instructions for installation can be found here. Note that you may need to install sqlcmd on your local machine, which can be done via brew install sqlcmd. In summary:

  1. Install Docker
  2. From a Docker terminal, pull the Microsoft-provided SQL Server container image with

sudo docker pull mcr.microsoft.com/mssql/server:2022-latest

  1. Start the container image running with

sudo docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=<YourStrong@Passw0rd>" -p 1401:1433 --name sql1 --hostname sql1 -d mcr.microsoft.com/mssql/server:2022-latest

If you need to stop the image, you can run sudo docker stop sql1. This is the step that will need to be run each time you do any development if your image was stopped after your previous development session.

  1. Change your SQL Server connection string to connect to the Docker container. This will be found in the appsettings.Development.json file in the repo. Edit the PuzzleServerContextLocal string to be

Server=localhost,1401;Database=PuzzleServer;User Id=SA;Password=<YourStrong@Passw0rd>;Trust Server Certificate=True;

Also make sure that your local changes to this file are added to your .gitignore so that they aren't pushed back into the repo. Once you've completed these steps, you can continue with the EF Core installation instructions above.

Clone this wiki locally