I’ve got a database project in Visual Studio that uses bulk import during its post-deployment tasks. This works perfectly if I give the full path to the file; aka “c:...”. I would like to convert this to use build variables so that I don’t need to give it the full absolute path to the files. Something closer to $(SolutionDir)$(OutDir)\file.csv.
I have tried many different variations, but I can’t figure out the correct path. I also tried using the “!!” command to figure out what directory the scripts are running in. That resulted in a failed build since external commands are disabled.
These are the paths that didn’t work
BULK INSERT [My].[Table] FROM ‘file.csv’ WITH /* blah blah blah */
file.csv
.\file.csv
.\path\to\output\file.csv
.\path\relative\to\solution\file.csv
Does anyone know how to access the files relative to the built Script.PostDeployment.sql file? Anyone know how to get “$(SolutionDir)$(OutDir)\file.csv” to work with SQL variables so that I can include it in the script file?