是否可以使用 SSIS 包 dtsConfig 文件的相对路径?
我试图使我们的 SQL Server Integration Services 包尽可能可移植,但阻碍这一点的一件事是配置的路径始终是绝对路径,这使得测试和部署变得令人头疼。 有什么建议可以让这更容易管理吗?
另一个问题是,当另一个开发人员将包从源代码控制中获取时,路径是特定于开发人员计算机的。
I am trying to make our SQL Server Integration Services packages as portable as possible and the one thing that is preventing that is that the path to the config is always an absolute path, which makes testing and deployment a headache. Are there any suggestions for making this more manageble?
Another issue is when another developer gets the package out of source control the path is specific to the developers machine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您尝试使用 Visual Studio 执行包,那么配置文件路径将被硬编码在其中。 因此,如果您移动项目,则需要更改包设置中的路径。 为了避免这种情况,您可以使用环境变量选项来存储配置文件路径。 那么你只需要改变它。
但是,对于测试和部署,您可能应该使用 dtexec 实用程序来执行包。 为此制作一些批处理文件。 最好针对每个不同的环境使用一个。 这里的配置文件路径可以是相对的。
这是如果你的包位于文件系统上的话。 您还可以将它们存储在 SQL Server 中。 您还可以将配置存储在 SQL Server 中,这可以提供灵活性。
If you are trying to execute your packages using Visual Studio then the configuration file path will be hardcoded in there. So if you move your project around you'll need to change the path in the package settings. To avoid this you could use the Environment variable option to store the configuration file path. Then you'll only need to change that.
For testing and deployment however you should probably use the dtexec utility to execute your packages. Make some batch files for that. Preferably one for each different environment. Here the configuration file path can be relative.
This is if you're packages are on file system. You can also store them in SQL Server. You can also store your configuration in SQL Server which may provide flexibility.
经过几个小时的努力,我找到了一个解决方案 此处(不是最好的,但它有效)
,否则相对路径对我不起作用。
After several hours trying to make this work I found a solution here (not the best one, but it works)
Otherwise the relative paths did not work for me.
查看无需 BIDS 即可编辑 SSIS 配置文件路径的免费实用程序:
http://ssisconfigeditor.codeplex.com/
Check out the free utility that can edit SSIS configuration file paths without BIDS:
http://ssisconfigeditor.codeplex.com/
对于这类问题,我常用的标准技巧是映射驱动器。
通过使用映射网络驱动器 或使用 Subst(两种方法可以互换)。
例如,将包的位置映射到 N:\,然后在包内使用 N:\MyParentPackage.dtsx、N:\MyChildPackage.dtsx 的路径。 这些包可以位于不同计算机上不同文件夹中的完全不同的驱动器上,一旦将包位置映射到 N:\
我通常会在项目文件旁边放置一个脚本来映射驱动器,该脚本会映射驱动器之前可以轻松运行。 一个问题是,如果您在 VISTA - Win8 上使用 subst,请将其映射为提升和非提升。
我对 Visual Studio 项目中的文件引用使用相同的方法。 这种方法的唯一问题是,您用来解决开发环境中的太多问题,并且您将用完驱动器号。
My stock standard trick for these sorts of problems are mapping drives.
Either by using a mapped network drive or by using Subst (both methods are interchangable).
e.g. Map the location of your package to N:\ then inside your package use paths using N:\MyParentPackage.dtsx, N:\MyChildPackage.dtsx. The packages can be on totally different drives in different folders on different machines, it'll work once you map the package location to the N:\
I usually put a script along side the project files to map the drive, which maps the drive so it can be easily run before. One gotcha, if you're using subst on VISTA - Win8, map it for elevated and non-elevated.
I use the same approach for file references in Visual Studio projects. Only issue with this approach, you use to solve too many issues in your dev environment and you'll run out of drives letters.