简体   繁体   中英

The type or namespace name 'Management' does not exist in the namespace 'Microsoft.SqlServer' - SqlParser and VSTS automated builds

I am using the Parser that is part of Microsoft.SqlServer.Management.SqlParser.Parser namespace in order to parse a Sql statement and it works fine when testing, however; the build fails in VSTS with the following error:

Error CS0234: The type or namespace name 'Management' does not exist in the namespace 'Microsoft.SqlServer' (are you missing an assembly reference?)

I have referenced the library by adding a reference to Microsoft.SqlServer.Management.SqlParser using the add reference context and selecting Extensions.

I have the following import

using Microsoft.SqlServer.Management.SqlParser.Parser;

and am executing the Parser

var rst = Parser.Parse(sqlStr);  
return Json(rst.Errors, JsonRequestBehavior.AllowGet);

I am assuming I need additional libraries in order to build in VSTS but am not sure which? Perhaps these libraries does not build on VSTS? Please assist with a solution.

If you are targeting SQL server 2017, then you will need to include the SMO NuGet package in your project.

Otherwise you will need to install the SharedManagementObjects.msi from the Feature Pack of the SQL server version and service pack level you are targeting or referencing.

SQL Server 2016 SP2 Feature Pack
SQL Server 2014 SP2 Feature Pack
SQL Server 2012 SP4 Feature Pack

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM