从网站中排除在Visual Studio中发布的文件 [英] Exclude files from web site publish in Visual Studio

查看:152
本文介绍了从网站中排除在Visual Studio中发布的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio 2005中发布网站时,可以排除文件夹或文件吗?我想在解决方案资源管理器中保留各种资源,例如用于各种环境的备用配置文件,但是我真的不想将它们发布到服务器.有什么方法可以排除它们吗?当使用其他项目类型(例如.dll程序集)时,我可以将文件的Build Action属性设置为"None",并将其Copy to Output Directory属性设置为"Do not copy".我在网站上找不到文件的任何类似设置.

Can I exclude a folder or files when I publish a web site in Visual Studio 2005? I have various resources that I want to keep at hand in the Solution Explorer, such as alternate config files for various environments, but I don't really want to publish them to the server. Is there some way to exclude them? When using other project types, such as a .dll assembly, I can set a file's Build Action property to "None" and its Copy to Output Directory property to "Do not copy". I cannot find any similar settings for files in a web site.

如果IDE不提供此功能,那么有没有人能很好地处理此类文件?

If the IDE does not offer this feature, does anyone have good technique for handling such files?

推荐答案

如果您可以基于扩展名识别文件,则可以使用

If you can identify the files based on extension, you can configure this using the buildproviders tag in the web.config. Add the extension and map it to the ForceCopyBuildProvider. For example, to configure .xml files to be copied with a publish action, you would do the following:

<configuration>...
    <system.web>...
        <compilation>...
            <buildProviders>
                <remove extension=".xml" />
                <add extension=".xml" type="System.Web.Compilation.ForceCopyBuildProvider" />
            </buildProviders>

要防止复制给定的文件,您可以做相同的事情,但要使用System.Web.Compilation.IgnoreFileBuildProvider作为类型.

To keep a given file from being copied, you'd do the same thing but use System.Web.Compilation.IgnoreFileBuildProvider as the type.

这篇关于从网站中排除在Visual Studio中发布的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆