安装VSIX项目时如何将文件复制到任意位置?
我正在开发 Visual Studio 2010 扩展(VSIX 项目),以向实体框架设计器中的实体添加一些额外的属性。除了为 MEF 发现注册适当的类之外,我还希望将 T4 包含文件复制到 %ProgramFiles%\ Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Entity 安装扩展时,我在 Framework Tools\Templates\Includes
文件夹中找到了该文件夹,但我不知道如何执行此操作,并且 VSIX 属性页面似乎没有显示任何选项。
所以我的问题是:有什么方法可以在安装 VSIX 项目时将给定文件复制到给定位置吗?
I am developing a Visual Studio 2010 extension (VSIX project) to add some extra properties to the entities in the Entity Framework designer. In addition to registering the appropriate classes for MEF discovery, I would like a T4 include file to be copied to the %ProgramFiles%\
folder when the extension is installed, but I don't know how to do it and the VSIX properties page does not seem to show any option for this.
Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Entity
Framework Tools\Templates\Includes
So my question is: is there any way to have a given file being copied to a given location when a VSIX project is installed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅使用 VSIX,不,没有。
VSIX 包的全部内容在安装过程中只需解压缩到本地扩展目录中 - 关于文件安装就到此为止。
无论您想在任何地方复制什么,都必须在 VSIX 安装程序之外进行处理。例如 - 使用不同的安装程序。或者,再举一个例子,在第一次运行插件时,在 package.Initialize() 中的某个位置,检查有问题的文件是否存在于正确的位置,如果不存在 - 将它们复制到那里。
当然,如果你想写入ProgramFiles目录,你面前还有另一个障碍:UAC保护。要在那里写入,您将需要一个另一个可执行文件,您的插件将在高程中运行该可执行文件(并在此期间请求用户许可等),并且只有它才能将文件复制到那里。好吧,当然,除非您高兴地假设每个人都始终“以管理员身份”运行其 VisualStudio,而忽略 UAC 和用户的眼泪。
Using VSIX only, no, there is not.
Whole contents of VSIX package are during installation simply unzipped into your local extensions directory - and that's END regarding file installations.
Whatever you want to copy anywhere, you must deal with it outside of the VSIX installer. For example - use different installer. Or, for another example, upon first-run of your plugin, somewhere in package.Initialize(), check whether the files in question exist in right places, and if not - copy them there.
Of course, if you want to write to the ProgramFiles directory, you have another barrier in front of you: the UAC protection. To write there, you will need an another executable that your plugin will run in elevation (and asking the user for permission during that, etc) and it only it will be able to copy the files there. Well, of course, unless you happily assume that everyone always run their VisualStudios "as administrator" and simply ignore the UAC and your users' tears.