不要在 ASP.NET 中发布特定文件夹

发布于 2024-07-17 23:05:14 字数 150 浏览 10 评论 0原文

是否可以排除 Web 项目中的文件夹被发布? 我们有一些文档和脚本包含在特定的项目文件夹中,并添加到项目中,但是当我进行 VS 发布时,我不希望它们进入生产服务器。

我知道它们不应该出现在项目中,但我想在尝试说服所有者修改他的工作方式之前我应该​​找到解决方法。

Is it possible to exclude a folder in a web project from being published? We've got some documentation and scripts that included in a particular project folder, and are added to the project, but when I do a VS publish, I don't want them to go up to the production server.

I know they shouldn't be in the project, but I thought I'd find a workaround before I try to convince the owner to modify the way he's doing things.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

友谊不毕业 2024-07-24 23:05:14

老问题,但我发现如果我在 Windows 资源管理器中将该文件夹标记为隐藏,它不会在您的解决方案中显示/发布。

例如,这可以很好地阻止原始 Photoshop 图像包含在未使用且较大的上传中。 任何更复杂的东西,尽管您可能想要编写自己的发布工具。

Old question, but I found if I mark the folder as hidden in Windows Explorer, it doesn't show/publish in your solution.

This is good for example to stop original photoshop images being included in uploads which aren't used and are big. Anything more complex though you'll probably want to write your own publish tool.

转身泪倾城 2024-07-24 23:05:14

这并不能准确地回答您的问题,但我的感觉是,除非您是发布到服务器的单个开发人员,否则最好使用 MSBuild (或其他一些构建和部署解决方案)在专用工作站或服务器上进行构建直接(从而能够非常精细地控制生产过程中的内容)。 MSBuild不仅可以构建,而且使用一些扩展(包括开源类型),它还可以部署。 微软有一个名为 MSDeploy 的测试版产品,这可能是一个更好的选择,但由于没有使用它的经验,我不能肯定地说。

在我们的情况下,我们有一个虚拟工作站作为构建框,我们所要做的就是双击启动 MSBuild 项目的批处理文件。 它使用 VSS 标记所有代码,获取最新版本,构建解决方案,然后将其部署到两台服务器。 我们准确地部署我们想要部署的内容,仅此而已。 我们对此非常满意。

唯一的缺点(如果可以被视为缺点的话)是我们中至少有一个人必须学习如何使用 MSBuild。 VS本身使用MSBuild。

This doesn't answer your question, exactly, but my feeling is that unless you are a single developer publishing to a server, you would be better off doing builds on a dedicated workstation or server using MSBuild (or some other building and deploying solution) directly (and thereby would be able to very granularly control what goes up to production). MSBuild can not only build, but using some extensions (including open source types), it can also deploy. Microsoft has a product called MSDeploy in beta, and that might be an even better choice, but having no experience with it, I cannot say for certain.

In our situation, we have a virtual workstation as a build box, and all we have to do is double click on the batch file that starts up an MSBuild project. It labels all code using VSS, gets latest version, builds the solution, and then deploys it to both servers. We deploy exactly what we want to deploy and nothing more. We're quite happy with it.

The only downside, if it could be considered a downside, is that at least one of us had to learn how to use MSBuild. VS itself uses MSBuild.

生活了然无味 2024-07-24 23:05:14

对于您不想删除的文件,请在属性中循环并将“复制到输出目录”设置为“不复制”。

但是,此选项不适用于目录。

For the files you don't want to go, loop at the properties and set the 'Copy to Output Directory' to 'Do not copy'

This option is not available for directories, however.

手长情犹 2024-07-24 23:05:14

难道你不能通过Visual Studio将它们排除在项目之外以阻止它们被发布吗? 它们仍然存在于文件系统中

Can you not exclude them from the project through visual studio to stop them being published. They will the still exist in the filesystem

无悔心 2024-07-24 23:05:14

据我所知,您可以执行此操作的唯一方法是将其从项目中排除,进行发布,然后将其重新包含在项目中。 这可能是一个问题。

The only way that you can do this to my knowledge would be to exclude it from the project, do the publish, then re-include it in the project. That can be an issue.

携君以终年 2024-07-24 23:05:14

可能有更好的方法来解决这个问题,但是当我们为开发服务器发布构建时,我们将在构建完成后运行一个批处理文件以删除不需要的文件夹和 web.configs(因此我们不会覆盖已经部署的)。

There are probably much better ways to solve this problem but when we publish a build for our dev servers, we'll run a batch file when the build is complete to remove the un-needed folders and web.configs (so we don't override the ones that are already deployed).

微暖i 2024-07-24 23:05:14

根据 http ://www.mahinupta.com/mahinupta/blog/post/2009/12/04/AspNet-website-Exclude-folder-from-compilation.aspx 您只需为该文件夹赋予“隐藏”属性即可Windows 资源管理器,它不会发布。 我测试了这个,它对我有用。

似乎是一个简单的解决方案,用于快速和肮脏的目的,但我不认为它会通过我们的版本控制(mercurial)。

According to http://www.mahingupta.com/mahingupta/blog/post/2009/12/04/AspNet-website-Exclude-folder-from-compilation.aspx you can just give the folder the "hidden" attribute in windows explorer and it won't publish. I tested this and it works for me.

Seems like a straightforward solution for quick and dirty purposes, but I don't think it will carry through our version control (mercurial).

七分※倦醒 2024-07-24 23:05:14

选择所有不应发布的文件。

转到属性

构建动作 -> 无

在此处输入图像描述

必须对每个子目录重复此过程。

Select all the files that should not be published.

Go to Properties
Set
Build Action -> None

enter image description here

Have to repeat the process for each sub-directory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文