سؤال

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?

هل كانت مفيدة؟

المحلول 2

DACPAC files are actually zip files. Extract the zip and query the file DacMetaData which is a xml file. Use the XPath: /DacType/Version

نصائح أخرى

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;
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top