Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the version number from a DACPAC file

I generate DACPAC files from automated builds with a generated version number. While useful during sqlpackager operations I need to be able to determine the version number of a DACPAC before doing anything with the file.

What tooling can I use (automated of course) to query the DACPAC file for its version number and description?

like image 710
BozoJoe Avatar asked May 10 '13 16:05

BozoJoe


1 Answers

Hey I know you found a solution but I have an alternative method that may help someone else. By referencing Microsoft.SqlServer.Management.Dac.dll and using the DacType class:

using System.IO;
using Microsoft.SqlServer.Management.Dac;

(Not entirely sure which using statements are needed - I have copied for a larger DAC helper file)

using (Stream dacPackFileStream = File.Open(this.dacPackFileName, FileMode.Open))
{
     var dacType = DacType.Load(dacPackFileStream);
     dacPackFileStream.Close();
     return dacType.Version;
}
like image 54
Mark Avatar answered Oct 16 '22 14:10

Mark