获取自定义任务SSIS的项目目录
我正在构建一个自定义 SSIS 任务。在任务中,我运行一些脚本。它们位于项目/子文件夹scripts/中。
现在的问题是,当我从 BIDS 调试我的任务时:
Directory.GetCurrentDirectory();
返回: C:\Program Files (x86)\Microsoft Visual 9.0\Common7
但如果我从 Visual Studio 运行/调试(使用 DTExec)我得到:
C:\Users\nwadike\Documents\Visual Studio 2008\Projects\BloombergRequest\BloombergRequest\bin
现在如果我使用:System.Reflection.Assembly.GetCallingAssembly().Location
, 我得到:C:\Windows\assemble\GAC_MSIL\BloombergRequest\versionNum\BBG.dll
无论我是从 SSIS 还是 Visual studio 进行调试...
基本上我正在寻找如何获得相对的项目\脚本\的路径....这怎么可能?
I am building a custom SSIS task. In the task, I run some scripts. These are located in the project/ in a subfolder scripts/.
Now the problem is when I debug my task from BIDS:
Directory.GetCurrentDirectory();
returns: C:\Program Files (x86)\Microsoft Visual 9.0\Common7
But if I run/debug from visual studio (with DTExec) I get:
C:\Users\nwadike\Documents\Visual Studio 2008\Projects\BloombergRequest\BloombergRequest\bin
Now if I use: System.Reflection.Assembly.GetCallingAssembly().Location
,
I get: C:\Windows\assembly\GAC_MSIL\BloombergRequest\versionNum\BBG.dll
whether I debug from SSIS or Visual studio...
Basically I am looking for how to get a relative path to project\scripts\.... How is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SSIS 中无法获取 Visual Studio 项目中特定文件夹的相对路径 - 这是有道理的,因为整个 Visual Studio 项目通常不会随包一起部署。而且,正如您所指出的,“当前目录”的概念没有帮助,因为它基于可执行文件的运行位置,而不是源代码所在的位置。
然而,有一个(某种程度上)简单的解决方法。
$(SolutionDir)/project/scripts
作为参数传递; 或There is no way within SSIS to get a relative path to a particular folder in a Visual Studio project - which makes sense, since the whole Visual Studio project normally doesn't get deployed with the package. And, as you noted, the concept of the "current directory" doesn't help, as it's based on where the executable is run from, not where the source code lives.
However, there's a (sort-of) straightforward workaround.
$(SolutionDir)/project/scripts
as an argument; or使用:
use: