ssdt linux defaultdatapath
When using SSDT to publish against SQL Server running on Linux $defaultDataPath and $DefaultLogPath builtin variable are always empty, which results in an error (see below) when attempting to create a database with additional data files. because of invalid filepath.
Additional File Definition in db project:
ALTER DATABASE [$(DatabaseName)]
NAME = [FooName],
FILENAME = '$(DefaultDataPath)$(DefaultFilePrefix)_FooName.ndf',
SIZE = 1024 MB,
FILEGROWTH = 1024MB
) TO FILEGROUP [FooFileGroup]
Msg 5105, Level 16, State 2, Line 14
A file activation error occurred. The physical file name 'FG_Indexes.ndf' may be incorrect. Diagnose and correct additional errors, and retry the operation.
Msg 5009, Level 16, State 8, Line 14
One or more files listed in the statement could not be found or could not be initialized.
Malcolm Smith commented
Can SSDT code be updated from check of variables from Windows Registry to Server Properties
DefaultDataPath = SERVERPROPERTY('InstanceDefaultDataPath')
DefaultLogPath = SERVERPROPERTY('InstanceDefaultLogPath')
This could be switch for DB versions SQL2017 or later only
Additional issue for PreDeployment, as PreDeployment runs AFTER CREATE DATABASE statements and not PRE deployment Code, so unable to use own dynamic SQLCMD created in the PreDeployment Script