-
Notifications
You must be signed in to change notification settings - Fork 159
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 version of .Net Core corresponding to the version in global.json from https://www.microsoft.com/net/download/dotnet-core
- Select the platform for your current OS and install
[Update: if you get error after run dotnet restore, try uninstalling earlier versions of .NET Core and then installing the version from step 1]
- Set up CLI or IDE integration (optional):
- Option 1: Visual Studio Code support: install VSCode, go to the Extensions tab and type "C#". Install the extension and restart VSCode
- Option 2: 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
- 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.ServiceLayerfolder - Run
dotnet restoreto restore dependencies - Run
dotnet build [-r|--runtime]to build the project and its dependencies separately. By default this will create a folder insrc/Microsoft.SqlTools.ServiceLayer/bin/Debugthat will contain the built binaries. - Run
dotnet publish [-r|--runtime]to create the project and its full set of dependencies needed for runtime. These will be created insrc/Microsoft.SqlTools.ServiceLayer/bin/Debug/netcoreapp#.#/publishby default.
[Update: try dotnet build --runtime win10-x64 for windows10 if you have error during build]
Note If you are adding/modifying strings in the sr.strings file then you will need to run the full build script, see https://github.com/microsoft/sqltoolsservice/blob/main/BUILD.md#build for more details.
- Open Visual Studio, go to
File -> Open -> Project/Solution, and open the<root>/sqltoolsservice.slnsolution file - This will open the project and should automatically initiate a
dotnet restoreaction for you - Open
Test -> Windows -> Test Explorerand 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>/testfolder and rundotnet restore. This will restore for all test projects - The main unit tests are under
<root>/test/Microsoft.SqlTools.ServiceLayer.UnitTests. Rundotnet buildon this
- Navigate to the
- Run
dotnet testin 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.testfrom 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 testanddebug testappearing 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.
- Go to the
test\Microsoft.SqlTools.ServiceLayer.TestEnvConfigdirectory in a command window and run the following command to generate the settings:dotnet run [path to the instances xml file]
Once this is done, you can run just the integration tests by going to the test\Microsoft.SqlTools.ServiceLayer.IntegrationTests directory in a command window and running dotnet test