1

I am using localdb for some Entity Framework repository integration unit tests. I have implemented a standard build configuration and after initial problems read that I should initialise and start the SQL Local DB. To that end I added the following to test project post-build:

"C:\Program Files\Microsoft SQL Server\120\Tools\Binn\SqlLocalDB.exe" create "V12.0" 12.0 -s

but I was getting errors locally and in Visual Studio Online Build like:

The sp_configure value 'contained database authentication' 
must be set to 1 in order to create a contained database.  
You may need to use RECONFIGURE to set the value_in_use.

So after some research I then added the following.

sqlcmd -S "(localdb)\V12.0" -Q "EXEC sys.sp_configure N'contained database authentication', N'1';"
sqlcmd -S "(localdb)\V12.0" -Q "RECONFIGURE WITH OVERRIDE;"

This fixed things locally, but in VSO build agent I still get errors. It appears that the localdb is initialized OK, but then the SQLCMD can locate the server instance just created. Log below.

"C:\Program Files\Microsoft SQL Server\120\Tools\Binn\SqlLocalDB.exe" create "V12.0" 12.0 -s

sqlcmd -S "(localdb)\V12.0" -Q "EXEC sys.sp_configure N'contained database authentication', N'1';"

sqlcmd -S "(localdb)\V12.0" -Q "RECONFIGURE WITH OVERRIDE;"
LocalDB instance "V12.0" created with version 12.0.2000.8.

LocalDB instance "V12.0" started.

HResult 0xFFFFFFFF, Level 16, State 1
SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. 
Sqlcmd(0,0): Error : Microsoft SQL Server Native Client 10.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
Sqlcmd : error : Microsoft SQL Server Native Client 10.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.. [D:\a\1\s\src\dotNET\hms.entappsettings.webapi\hms.entappsettings.repository.Tests\hms.entappsettings.repository.Tests.csproj]
Sqlcmd(0,0): Error : Microsoft SQL Server Native Client 10.0 : Login timeout expired.
Sqlcmd : error : Microsoft SQL Server Native Client 10.0 : Login timeout expired. [D:\a\1\s\src\dotNET\hms.entappsettings.webapi\hms.entappsettings.repository.Tests\hms.entappsettings.repository.Tests.csproj]
HResult 0xFFFFFFFF, Level 16, State 1
SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. 
Sqlcmd(0,0): Error : Microsoft SQL Server Native Client 10.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
Sqlcmd : error : Microsoft SQL Server Native Client 10.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.. [D:\a\1\s\src\dotNET\hms.entappsettings.webapi\hms.entappsettings.repository.Tests\hms.entappsettings.repository.Tests.csproj]
Sqlcmd(0,0): Error : Microsoft SQL Server Native Client 10.0 : Login timeout expired.
Sqlcmd : error : Microsoft SQL Server Native Client 10.0 : Login timeout expired. [D:\a\1\s\src\dotNET\hms.entappsettings.webapi\hms.entappsettings.repository.Tests\hms.entappsettings.repository.Tests.csproj]
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4714,5): Error MSB3073: The command ""C:\Program Files\Microsoft SQL Server\120\Tools\Binn\SqlLocalDB.exe" create "V12.0" 12.0 -s
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(4714,5): error MSB3073: The command ""C:\Program Files\Microsoft SQL Server\120\Tools\Binn\SqlLocalDB.exe" create "V12.0" 12.0 -s [D:\a\1\s\src\dotNET\hms.entappsettings.webapi\hms.entappsetting

Any help would be greatly appreciated.

NER1808
  • 1,829
  • 2
  • 33
  • 45
  • Have you tried using the sqllocaldb .NET library, which was created for just scenarios like this? – ErikEJ Feb 16 '17 at 19:23
  • @ErikEJ No. Have you got any links I can look at? – NER1808 Feb 16 '17 at 19:25
  • https://github.com/martincostello/sqllocaldb – ErikEJ Feb 16 '17 at 19:54
  • Could you manually run `SqlLocalDB.exe` command in your build agent successfully? – PatrickLu-MSFT Feb 17 '17 at 10:45
  • @Patrick-MSFT I'm not sure how to get an interactive console in Visual Studio Online build agent. The initial SqlLocalDB.exe command creating the instance runs OK, but the sqlcmd.exe commands can't seem to locate the server using the '(localdb)\V12.0' connection. – NER1808 Feb 24 '17 at 11:14
  • login timeout expired. Seems related to the authentication. Did your build service account have enough related permission with local DB? – PatrickLu-MSFT Feb 27 '17 at 17:03

0 Answers0