在安装和部署中嵌入SMO dll

时间:2023-02-12 04:49:39

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?

我有一个.NET Set and Deployment项目,它必须执行一组非常长的SQL脚本作为安装过程的一部分。我已经使用SMO dll来调用.sql脚本文件。然而,这些SMO dll不是.NET框架的一部分,但它们与SQL Server 2005或2008捆绑在一起。现在,如果设置在一台机器上运行没有安装SQL Server 2005/2008的SQL脚本执行失败。这是我的设置的完全有效的用例,因为用户可能在其本地计算机上但在网络服务器上没有SQL Server。我如何将SMO dll与设置.msi一起嵌入,以便它不必依赖于正在运行的机器上的任何SMO dll?

2 个解决方案

#1


0  

A simple way to do it would be to add those files to the deployment project.

一种简单的方法是将这些文件添加到部署项目中。

If you right click on the project in solution explorer then select View > File System you could add those files under the target machine's application folder.

如果右键单击解决方案资源管理器中的项目,则选择“视图”>“文件系统”,然后可以在目标计算机的应用程序文件夹下添加这些文件。

If you need to register the dll's I think you can add a custom action to do that, but I'm not sure.

如果您需要注册dll,我认为您可以添加自定义操作来执行此操作,但我不确定。

Hope that helps!

希望有所帮助!

#2


0  

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

对不起,乍看之下我不明白这个问题。我会做以下事情:

  1. Create a custom installer project (Class Library)
  2. 创建自定义安装程序项目(类库)

  3. Add a reference to the SMO DLLs (I think you have to set Copy Local = True)
  4. 添加对SMO DLL的引用(我认为你必须设置Copy Local = True)

  5. Add an installer class to it with your sql deployment logic
  6. 使用sql部署逻辑为其添加安装程序类

  7. Add this project's output to your setup project
  8. 将此项目的输出添加到您的安装项目

  9. Setup the necessary custom actions
  10. 设置必要的自定义操作

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

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

Hope that helps!

希望有所帮助!

#1


0  

A simple way to do it would be to add those files to the deployment project.

一种简单的方法是将这些文件添加到部署项目中。

If you right click on the project in solution explorer then select View > File System you could add those files under the target machine's application folder.

如果右键单击解决方案资源管理器中的项目,则选择“视图”>“文件系统”,然后可以在目标计算机的应用程序文件夹下添加这些文件。

If you need to register the dll's I think you can add a custom action to do that, but I'm not sure.

如果您需要注册dll,我认为您可以添加自定义操作来执行此操作,但我不确定。

Hope that helps!

希望有所帮助!

#2


0  

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

对不起,乍看之下我不明白这个问题。我会做以下事情:

  1. Create a custom installer project (Class Library)
  2. 创建自定义安装程序项目(类库)

  3. Add a reference to the SMO DLLs (I think you have to set Copy Local = True)
  4. 添加对SMO DLL的引用(我认为你必须设置Copy Local = True)

  5. Add an installer class to it with your sql deployment logic
  6. 使用sql部署逻辑为其添加安装程序类

  7. Add this project's output to your setup project
  8. 将此项目的输出添加到您的安装项目

  9. Setup the necessary custom actions
  10. 设置必要的自定义操作

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

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

Hope that helps!

希望有所帮助!