C# 在安装项目中包含文件夹

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1108840/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 08:26:22  来源:igfitidea点击:

Include folder in setup project

c#visual-studiovisual-studio-2008installationsetup-project

提问by MichaelD

I want to include a folder in a setup project so that when I deploy that setup the complete folder is also deployed to the install location.

我想在安装项目中包含一个文件夹,以便在部署该安装程序时,完整的文件夹也会部署到安装位置。

采纳答案by dxh

Right click the setup project, and select "View" > "File System", and from there you can access a lot of special folders like install folder, appdata, desktop etc, and add files to there, that will be created when you install the application. Make sure to set the "alwayscreate" property to true.

右键单击安装项目,然后选择“查看”>“文件系统”,从那里您可以访问许多特殊文件夹,例如安装文件夹、appdata、桌面等,并向其中添加文件,这些文件将在您安装时创建应用程序。确保将“alwayscreate”属性设置为 true。

回答by CrnaStena

The answer is good because it gave me clue on how to fix my problem. I think that my requirement was slightly different. I had to include contents of another library project from the same solution. This seems to work fine for Console Applications/Web Sites, but Installer for some reason was not including it. There might be a better way, but this worked for me. In similar fashion, right click the setup project, and:

答案很好,因为它为我提供了如何解决问题的线索。我认为我的要求略有不同。我必须包含来自同一解决方案的另一个库项目的内容。这似乎适用于控制台应用程序/网站,但由于某种原因安装程序没有包含它。可能有更好的方法,但这对我有用。以类似的方式,右键单击安装项目,然后:

- Select "View" > "Custom Actions". 
- Right click on "Install" folder and select "Add Custom Action". 
- Double click on "Application Folder"
- Click on "Add Output..."
- Select the project from the dropdown and in my instance I selected "Content Files", OK it and give it a name. 

This will include any resources, from the selected project marked as Content and that are marked for copying, into your installer.

这将包括选定项目中标记为内容并标记为复制的任何资源到您的安装程序中。