-
Notifications
You must be signed in to change notification settings - Fork 153
Home
Welcome to the SQL Tools Service wiki! This is a .Net Core-based application supporting SQL Connection, Query Execution, Intellisense and other actions. It's intended for use together with a front-end app such as the MSSQL extension for Visual Studio Code. This wiki will focus primarily on how to build, test, and commit to this repository.
- Install .Net Core
- Install the .Net Core SDK from https://github.com/dotnet/core/blob/master/release-notes/download-archives/1.0.3-preview2-download.md
- Select the platform for your current OS and install
Note that the tools service is built against .NET Core 1.0 and the global.json explicitly requests version build 3156. Please download the VS2015 .NET Core tools from https://go.microsoft.com/fwlink/?LinkID=827546
- Set up CLI or IDE integration (optional):
- Option 1: Visual Studio Integration (for Windows dev): On the .Net Core install page there should be a link for .Net Core SDK for Windows. Click that and run the installer
- Option 2: Visual Studio Code support: install VSCode, go to the Extensions tab and type "C#". Install the extension and restart VSCode
- Start a command line
- Create a directory where you want to keep your repositories (e.g. C:\repos)
- Navigate to that directory and type
git clone https://github.com/Microsoft/sqltoolsservice.git
- Navigate to the
<root>/src/Microsoft.SqlTools.ServiceLayer
folder - Run
dotnet restore
to restore dependencies - Run
dotnet build [-r|--runtime]
to build the project - Run
dotnet publish [-r|--runtime]
to create the project and its dependencies in a way that's usable by vscode-mssql
- Open Visual Studio, go to
File -> Open -> Project/Solution
, and open the<root>/sqltoolsservice.sln
solution file - This will open the project and should automatically initiate a
dotnet restore
action for you - Open
Test -> Windows -> Test Explorer
and build the solution to view all available tests - You can run one or all tests easily from inside Visual Studio
- Build the test code in a similar way to src:
- Navigate to the
<root>/test
folder and rundotnet restore
. This will restore for all test projects - The main unit tests are under
<root>/test/Microsoft.SqlTools.ServiceLayer.Test
. Rundotnet build
on this
- Navigate to the
- Run
dotnet test
in the test project's folder to build and execute these unit tests- You should see a === TEST EXECUTION SUMMARY === that includes results of running the ServiceLayer unit tests
- Navigate to the /sqltoolsservice folder
- Run "code ." to launch VS Code
- On the lower-right of the status bar, you should see "3 Projects" listed (or similar). Click on this and choose
project.json/test/Microsoft.SqlTools.ServiceLayer.test
from the dropdown so that the main unit test project is selected - Open a test file, for example
test/LanguageServer/LanguageServiceTests.cs
- You should see options to
run test
anddebug test
appearing for each method. Click on these to execute / debug a specific test. For a full test run the command-line integration is still recommended.
The versioning scheme for this project follows the semver versioning system.
Tests run against real servers and databases for many end to end tests. To set this up:
Prerequisites
- A local SQL Server 2016 or SQL Server v.Next server
- An Azure server (for the Azure specific tests).
- Note that when submitting a PR, these tests will be run so can be skipped locally if this is a problem
If you have VSCode and the MSSQL extension installed
- Setup your connection strings in VSCode
- Open VSCode, hit F1 and choose "MS SQL: Connect"
- Choose to "Create Connection Profile", and add all the settings to connect to your local server
- Choose "Save Password" when prompted"
- Verify that your connection succeeded.
- Repeat this for your Azure SQL DB server connection
- Edit your connections to identify them for use in test runs
- Hit F1 and choose "User Settings"
- Find "mssql.connections" and you'll see your 2 new connection profiles
- For the local connection, add "serverType":"OnPrem".
- For the Azure connection, add "serverType":"Azure".
If you want to generate the settings
- Setup your connection instances xml file
- Create an xml file using the template test\Microsoft.SqlTools.ServiceLayer.TestEnvConfig\SQLConnectionInstancesTemplate.xml
- Add your connection information to the xml file. At this moment the tests are only looking for the defaultssql2016 instance as OnPrem and defaultSqlAzureV12 as Azure.
- Run the following command to generate the settings: Test\Microsoft.SqlTools.ServiceLayer.TestEnvConfig\generateSQLConnectionSettings.bat [path to the instances xml file]