嵌入SMO动态链接库的安装和部署动态链接库、SMO

2023-09-06 10:03:49 作者:夜尽天明

我有一个.NET设置和部署项目,必须执行一组很长的SQL脚本,在安装过程中的一部分。我已经使用SMO动态链接库来调用的.SQL脚本files.These SMO的DLL但不是.NET Framework的一部分,但他们来与SQL Server 2005或2008捆绑现在,如果安装程序运行在机器上不具有SQL Server 2005/2008安装了SQL脚本执行失败。这是一个非常有效的使用案例,我的设置作为用户可能没有SQL服务器上他的本地机器,但在网络服务器上。 我该如何使嵌入的SMO的DLL一起安装的.msi,以便它没有依赖于它的机器正在运行的任何SMO的dll?

I have a .NET Set and Deployment project which has to execute a set of really long SQL Scripts as a part of the installation process. I have used SMO dlls to make calls to the .sql script files.These SMO dlls are however not a part of the .NET framework but they come bundled with SQL Server 2005 or 2008. Now, if the setup is run on a machine which does not have SQL Server 2005/2008 installed the SQL script execution fails. This is a perfectly valid use case for my setup as the user might not have SQL server on his local machine but on a network server. How do i embedd the SMO dll's along with the setup .msi so that it doesnt have to depend on any SMO dlls on the machine it is being run?

推荐答案

我很抱歉,我不明白第一眼的问题。我会做到以下几点:

I'm sorry, I didn't understand the question at first glance. I would do the following:

创建一个自定义安装项目(类库) 添加引用SMO的DLL(我认为你必须设置复制本地=真) 添加一个安装程序类,它与你的SQL部署的逻辑 在该项目的输出添加到您的安装项目 设置必要的自定义操作

本文解释类似的过程(减去SMO调用),它基于这个MSDN文章。

This article explains a similar process (minus the SMO calls), it's based on this msdn article.

希望帮助!