在 Visual Studio 安装程序安装项目中创建文件夹
我已经构建了一个 Visual Studio (2010) 安装程序安装项目来部署基本的 WinForms 应用程序,并且我需要我的安装程序根据其运行的操作系统创建几个目录。例如,当安装程序在 Windows XP(及更早版本)上运行时,我需要创建:
Application Folder\NewFolder
如果安装程序在 Vista 或更高版本上运行,我需要在通用应用程序数据文件夹(即 C:\ProgramData )像这样:
Common Application Data Folder\NewFolder
我看到我可以通过 View -> 添加“自定义文件夹” “文件系统”,但我不确定如何声明这个新文件夹的 DefaultLocation 属性。它的默认值为 [TARGETDIR],但我不确定如何指定要创建的目录的位置。这可以通过 Visual Studio 安装程序安装项目来完成还是我运气不好?
I've built a Visual Studio (2010) Installer Setup project to deploy a basic WinForms app and I need my installer to create a couple of directories based on the OS that its running on. For example, when the installer is run on Windows XP (and earlier), I need to create:
Application Folder\NewFolder
If the installer is running on Vista or later, I need to create the directory below the Common Application Data Folder (i.e., C:\ProgramData) like this:
Common Application Data Folder\NewFolder
I see that I can add a "Custom Folder" via View -> "File System" but I'm not sure how to declare the DefaultLocation property for this new folder. It defaults to a value of [TARGETDIR] but I'm uncertain how to specify the location of the directory that I want to create. Can this be done with a Visual Studio Installer Setup project or am I out of luck?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Visual Studio 安装项目不支持此功能。
其他安装创作工具通过 键入 51 自定义操作(使用格式化文本设置的属性)。
基本上,您的默认 TARGETDIR 可以指向一个位置,而类型 51 自定义操作可以在安装过程中将其更改为另一位置。此自定义操作可以以 VersionNT 属性为条件。
This is not supported by Visual Studio setup projects.
Other setup authoring tools support this through a type 51 custom action (property set with formatted text).
Basically, your default TARGETDIR can point to one location and a type 51 custom action can change it to another location during install. This custom action can be conditioned with VersionNT property.
我终于通过 View -> 将两个文件夹位置添加到我的安装项目中来完成此工作。文件系统。然后我为每个文件夹指定了一个条件。对于我想在 XP 上创建的文件夹,我使用了“WindowsBuild < 6000”,对于 Vista/Windows 7 文件夹,我使用了“WindowsBuild >= 6000”。
I finally got this working by adding both folder locations to my setup project via View -> File System. Then I specified a Condition for each folder. For the folder I want to create on XP, I used "WindowsBuild < 6000" and for the Vista/Windows 7 folder, I used "WindowsBuild >= 6000".
在特殊文件夹中,您可以将 DefaultLocation 设置为 [CommonAppDataFolder]。
在 XP 上,这将解析为 c:\documents and settings\all users\application data
在 Win 7 上,这将解析为 c:\ProgramData
On your Special Folder, you can set the DefaultLocation to [CommonAppDataFolder].
On XP, this will resolve to c:\documents and settings\all users\application data
And on Win 7, this will resolve to c:\ProgramData