-
Notifications
You must be signed in to change notification settings - Fork 630
Running on Linux
This page documents the steps required and some gotchas for getting the code up and running on Linux.
(The instructions are currently specific to Ubuntu 16.04 and only tested there, but should be easily transferrable to other distros).
If you don't have it already, follow the instructions at: https://www.microsoft.com/net/core#linuxredhat to install .NET Core.
On Ubuntu I installed the following:
sudo apt install dotnet-dev-1.0.0-preview2-1-003177
If when running the code, you get errors similar to the following:
The specified framework 'Microsoft.NETCore.App', version '1.0.3' was not found.
Then try installing the version it is requesting, e.g.:
sudo apt install dotnet-sharedframework-microsoft.netcore.app-1.0.3
The options are to point at a SQL Server database in Azure, or to install SQL Server for Linux locally.
See the instructions at: https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-ubuntu
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list
sudo apt update
sudo apt install -y mssql-server
sudo /opt/mssql/bin/sqlservr-setup
Also get the SQL Server command line tools.
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
sudo apt update
sudo apt install mssql-tools unixodbc-dev-utf16
We can of course use any text editor for working with the code, but VS Code has good support for C# projects, as well as an extension for working with MS SQL.
Fork the AllReady repo on Github and clone it locally:
git clone https://github.com/<youraccount>/AllReady
Navigate into the top-level directory and do a restore:
cd AllReady
dotnet restore
Then navigate into the AllReadyApp.Core and build.
cd AllReadyApp/AllReadyApp.Core
dotnet build
Now build the webapp:
cd ../Web-App/AllReady
dotnet build
The connection string to the database needs to be tweaked in order to point at our SQL Server database.
Note that SQL Server on Linux doesn't have integrated security, so you will need to create and specify a user to login to the DB with.
If you set up SQL Server for Linux, run the sqlcmd program and
create a login and a user and give that user CREATE DATABASE
permissions:
/opt/mssql-tools/bin/sqlcmd-13.0.1.0 -U SA -P 's4p4ss!'
1> create login AllReadyAdmin with password = 'p4ssw0rd!';
2> go
1> create user AllReadyAdmin for login AllReadyAdmin;
2> go
1> grant create database to AllReadyAdmin;
2> go
In config.json, update the Data/DefaultConnection/ConnectionString
and Data/HangfileConnection/ConnectionString settings to something
like:
"ConnectionString": "Server=localhost;Database=AllReady;User ID=AllReadyAdmin;Password=p4ssw0rd!;MultipleActiveResultsets=true;"
Now we can run the database migrations:
dotnet ef database update
Now run the app with:
ASPNETCORE_ENVIRONMENT=Development dotnet run
Setting the environment variable ASPNETCORE_ENVIRONMENT=Development gives us more useful error messages in the app for diagnosis during development.
If you are getting errors such as:
The time zone ID 'Central Standard Time' was not found on the local computer.
then try running a find and replace on the code, with
Central Standard Time being replaced to GMT.
This is just a temporary fix until the main repo is updated
to resolve this issue.