Skip to content
Leila Lali edited this page Aug 18, 2017 · 32 revisions

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.

Setup and run the service

Prerequisites to build the repository

  1. Install .Net Core

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

  1. 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

Clone the repository

  • 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

Building

  • 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

Testing

Testing in Visual Studio

  • 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

Command-line testing

  • Build the test code in a similar way to src:
    • Navigate to the <root>/test folder and run dotnet restore. This will restore for all test projects
    • The main unit tests are under <root>/test/Microsoft.SqlTools.ServiceLayer.Test. Run dotnet build on this
  • 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

Testing in Visual Studio Code

  • 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 and debug 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.

Versioning Scheme

The versioning scheme for this project follows the semver versioning system.

One Time Setup to Run Integration, Performance and TestDriver Tests

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]
Clone this wiki locally