In a sql server 2012 sqlproj (SSDT database project) you use publishing profiles. You can start off by right-clicking your database project and choosing 'Publish'.
You can then set desired options and save these in a so-called publishing profile in your project. Double-clicking this profile launches the publishing wizard with the correct options set.
In your publish profile you can include hard-coded values for sqlcmd variables:
<ItemGroup>
<SqlCmdVariable Include="ProjectDirectory">
<Value>UNKNOWN</Value>
</SqlCmdVariable>
</ItemGroup>
If desired, you can update these with dynamic values during build. In your msbuild project:
<Target Name="SetProjectDirectoryInPublishXml">
<ItemGroup>
<Namespaces Include="nsMsbuild">
<Prefix>nsMsbuild</Prefix>
<Uri>http://schemas.microsoft.com/developer/msbuild/2003</Uri>
</Namespaces>
</ItemGroup>
<ItemGroup>
<SSDTPublishFiles Include="$(SolutionBinFolder)\**\*.publish.xml" />
</ItemGroup>
<MSBuild.ExtensionPack.Xml.XmlFile Condition="%(SSDTPublishFiles.Identity) != ''"
TaskAction="UpdateElement"
File="%(SSDTPublishFiles.Identity)"
Namespaces="@(Namespaces)"
XPath="//nsMsbuild:SqlCmdVariable[@Include='ProjectDirectory']/nsMsbuild:Value"
InnerText="$(MSBuildProjectDirectory)"/>
</Target>
This requires an extension to update the XML. I use the msbuild extension pack.
Credits for this mechanism go to Jamie Thomson