Search code examples
sql-server-data-toolsdac

DacFx ignores Cmd Variables: DefaultDataPath & DefaultLogPath


I'm using DacFX in a custom installer. I am trying to override the default data and log file locations by passing in the Cmd Variables DefaultDataPath & DefaultLogPath but the database's files are still getting created in the default locations. This seems like it should be very simple and easy but even after generating the script and saving it to a file and stepping through the code I can see that the DacOptions object has the right values for the SqlCommmandVariableValues but the generated script doesn't have the values. It seems like they are ignored.

dacOptions.SqlCommandVariableValues.Add("DefaultDataPath", dataPath);
dacOptions.SqlCommandVariableValues.Add("DefaultLogPath", logPath);

Solution

  • To put some closure on this I ended up finding a way to do this by using Deployment Contributors. An example of changing the DB location can be found in the DacFx Public Samples.