SqlCodeAnalyzeFilesTask |
![]() |
This topic the MSBuild SqlCodeAnalyzeFilesTask task that is available with SQL Enlight.

The task runs static analysis over specified script files and creates a report.
Parameters
Name |
Description |
---|---|
Quiet | Suppresses all except error output messages. |
InputPath |
Required. Input script files location.
Multiple files can be provided by separating each file with semicolon. The ‘-‘ prefix can be used to exclude specific files. Example: “c:my files*.sql” or “c:my filesfile1.sql;c:my filesfile2.sql;” |
Rules |
List of analysis rules or analysis groups which to be applied. The rules can be separated with ‘,’,’;’ or ‘|’.
Example: sa0001,sa0002,ex0018,Performance,Design |
ParametersFile |
Path to an XML file containing the values for the analysis rules parameters. Check the XmlAnalysisParameters.xml for example and the SchemasAnalysisParameters.xsd for the parameters file XML schema. |
ContextFile |
Path to an analysis context file which to be used for analyzing the target script files. Analysis context file for specific database can be created using the command line tool with the analysiscontext command. |
ConnectionString |
Optional. Connection string to the target context database. If provided, the ServerName, DatabaseName, Username and Password parameters are ignored. |
ServerName |
Deprecated. Context SQL Server name. |
DatabaseName |
Deprecated. Context database name. |
Username |
Optional. Username for accessing the context database. If omitted integrated security will be used. |
Password |
Optional. User password for accessing the context database. If omitted integrated security will be used. |
TemplateFile |
Optional parameter for setting external analysis template. The external template will be used as a source for the analysis rules instead of the default template. See Analysis Template Import/Export topic for information how to save existing template in a file. |
ReportOutputPath |
Output location of the analysis report. Example: “c:my reportsanalysis1.xml” |
ReportStylesheetPath |
XSLT document that to be used to transform the report XML. Example: “C:Program FilesUbitsoftSQL EnlightXsltSqlEnlightReport.xslt” |
FailOnRuleViolation |
If TRUE, the task will fail if a single rule violation is found, otherwise the build script can decide whether to fail the build or not. Default value is FALSE. |
ViolationsCount | Output parameter returning the total number of rule violations. The number includes all rule violations not considering their type. |
ObjectsCount | Output parameter returning the total number analyzed objects. |
IncludeSubfolders | Include files in sub folders. |
MaxAge |
Optional. MAXimum file or database object AGE – exclude objects older than given date or time interval. |
Verbosity |
Output verbosity level. Supported values: quiet, normal and detail. |
SettingsFile |
A settings file which to override the current user’s settings XML file. Can be used to override some of the options which are not available as parameters for the command line tool, MSBuild and NAnt tasks, but are configurable using SQL Enlight user interface. See Settings XML File for more details. |
LicenseKey |
Required. SQL Enlight for Build Machines license key. |
LicenseData |
Required. Path to a license activation response XML file. |
Example
Example MSBuild project SqlCodeAnalyzeFilesTask
1<?xml version="1.0" encoding="utf-8"?> 2<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 3 4<UsingTask TaskName="Ubitsoft.SqlEnlight.Tasks.SqlCodeAnalyzeFilesTask" 5AssemblyFile="C:Program Files (x86)UbitsoftSQL EnlightUbitsoft.SqlEnlight.Tasks.dll" /> 6 7<PropertyGroup> 8<SqlEnlight_AnalysisInputPath>E:ProjectsMyProjectSQL ScriptAdventureWorks2008R2.sql</SqlEnlight_AnalysisInputPath> 9<SqlEnlight_AnalysisServerName>.</SqlEnlight_AnalysisServerName> 10<SqlEnlight_AnalysisDatabaseName>AdventureWorks2008R2</SqlEnlight_AnalysisDatabaseName> 11<SqlEnlight_AnalysisUsername></SqlEnlight_AnalysisUsername> 12<SqlEnlight_AnalysisPassword></SqlEnlight_AnalysisPassword> 13<SqlEnlight_AnalysisRules>ex0018,Design,Performance</SqlEnlight_AnalysisRules> 14<SqlEnlight_AnalysisReportOutputPath>E:ProjectsMyProjectBuildReportsAdventureWorks2008R2_Script_AnalysisReport.html</SqlEnlight_AnalysisReportOutputPath> 15<SqlEnlight_ReportStylesheetPath>C:Program FilesUbitsoftSQL EnlightXsltSqlEnlightReport.xslt</SqlEnlight_ReportStylesheetPath> 16<SqlEnlight_AnalysisRulesParametersFile>C:Program Files (x86)UbitsoftSQL EnlightXmlAnalysisParameters.xml</SqlEnlight_AnalysisRulesParametersFile> 17<SqlEnlight_AnalysisContextFile>E:ProjectsMyProjectBuildContextAdventureWorks2008R2.xml</SqlEnlight_AnalysisContextFile> 18<SqlEnlight_AnalysisTemplateFile>C:Program Files (x86)UbitsoftSQL EnlightTemplatesAnalysisDefaultAnalysisTemplate.xml</SqlEnlight_AnalysisTemplateFile> 19<SqlEnlight_AnalyzedObjectsCount>0</SqlEnlight_AnalyzedObjectsCount> 20<SqlEnlight_AnalysisViolationsCount>0</SqlEnlight_AnalysisViolationsCount> 21<SqlEnlight_MaxAge>5</SqlEnlight_MaxAge> 22<SqlEnlight_Verbosity>detail</SqlEnlight_Verbosity> 23<SqlEnlight_LicenseKey>ABCD-1234-XYZ-QWER-AAAA</SqlEnlight_Refactorings> 24<SqlEnlight_LicenseData>E:SQL Enlightlicense-activation-response.XML</SqlEnlight_Refactorings> 25</PropertyGroup> 26 27 28<Target Name="AnalyzeSqlScriptsTarget"> 29 30<Message Text="Starting SQL script analysis..." /> 31<Message Text="Running analysis on SQL script '$(SqlEnlight_AnalysisInputPath)'..." /> 32 33<SqlCodeAnalyzeFilesTask 34FailOnRuleViolation="false" 35Quiet="true" 36Rules="$(SqlEnlight_AnalysisRules)" 37InputPath="$(SqlEnlight_AnalysisInputPath)" 38ReportOutputPath="$(SqlEnlight_AnalysisReportOutputPath)" 39ReportStylesheetPath="$(SqlEnlight_ReportStylesheetPath)" 40ParametersFile="$(SqlEnlight_AnalysisRulesParametersFile)" 41ContextFile="$(SqlEnlight_AnalysisContextFile)" 42ServerName="$(SqlEnlight_AnalysisServerName)" 43DatabaseName="$(SqlEnlight_AnalysisDatabaseName)" 44TemplateFile="$(SqlEnlight_AnalysisTemplateFile)" 45Verbosity="$(SqlEnlight_Verbosity)" 46MaxAge="$(SqlEnlight_MaxAge)" 47LicenseKey="$(SqlEnlight_LicenseKey)" 48LicenseData="$(SqlEnlight_LicenseData)"> 49<Output TaskParameter="ViolationsCount" PropertyName="SqlEnlight_AnalysisViolationsCount" /> 50<Output TaskParameter="ObjectsCount" PropertyName="SqlEnlight_AnalyzedObjectsCount" /> 51 52</SqlCodeAnalyzeFilesTask> 53 54<Error Text="SQL Enlight analysis reported $(SqlEnlight_AnalysisViolationsCount) rule violations, see $(SqlEnlight_AnalysisReportOutputPath) for details." 55Condition="$(SqlEnlight_AnalysisViolationsCount) > 0" /> 56 57<Message Text="Completed database script files analysis!" /> 58</Target> 59 60</Project>
