简体   繁体   English

Visual Studio-如何在MVC项目中将文件/文件夹标记为“不发布”?

[英]Visual Studio - how to mark file/folder in MVC project as Do Not Publish?

In my MVC project I have a folder called Documents and inside that are some .txt files. 在我的MVC项目中,我有一个名为Documents的文件夹,并且其中有一些.txt文件。 These have information relating to the inner workings of the website and one document has usernames & passwords (for the dev database, not live). 其中包含有关网站内部工作的信息,并且一个文档包含用户名和密码(对于开发数据库,​​不是实时的)。

When I publish to the server this folder gets copied up, which I do not want. 当我发布到服务器时,该文件夹将被复制,这是我不想要的。 In its properties, "Copy To Output Directory" is set to "Do not copy" but it still gets copied. 在其属性中,“复制到输出目录”设置为“不复制”,但仍会被复制。

In another project the Documents folder is in the Repository layer which compiles into a DLL and I don't see the folder or txt files on the server. 在另一个项目中,Documents文件夹位于Repository层中,该层可编译为DLL,但我在服务器上看不到该文件夹​​或txt文件。 The MVC project where I am having the issue doesn't have a layered architecture. 我遇到问题的MVC项目没有分层架构。 I could create a class library project for it but that seems silly. 我可以为此创建一个类库项目,但这似乎很愚蠢。

  • Set "Build Action" property of the file to "None". 将文件的“生成操作”属性设置为“无”。
  • You have already set the "Copy to Output Directory" to "Do not copy", so that is already covered. 您已经将“复制到输出目录”设置为“不复制”,因此已经介绍了。
  • Right-click your MVC project in the solution explorer. 在解决方案资源管理器中右键单击您的MVC项目。 Click "Package/ Publish Web", and make sure to select "Items to deploy" to "Only files needed to run this application" option. 单击“打包/发布Web”,并确保将“要部署的项目”选择为“仅运行此应用程序所需的文件”选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 对于Visual Studio MVC项目,将页面标记为“异步= true” - Mark page as “async = true” for a Visual Studio MVC Project 发布配置文件目标未运行 Visual Studio 2019 MVC 项目 - Publish Profile Targets Not Running Visual Studio 2019 MVC Project 如何在Visual Studio中正确显示MVC项目? - How do I make a MVC project appear properly in Visual Studio? 如何将 ASP.net MVC 应用程序从 Visual Studio 2013 发布到本地网络? - How do you publish an ASP.net MVC application from Visual Studio 2013 to your local network? 如何在Visual Studio 2012或Visual Studio 2013中打开旧的MVC项目? - How do I open an old MVC project in Visual Studio 2012 or Visual Studio 2013? 如何在Visual Studio 2017中创建MVC项目? - How to create MVC project in visual studio 2017? 如何让 Visual Studio 使用我的数据库,而不是位于 ASP.NET MVC 项目的 App_Data 文件夹中的 .mdf 文件? - How can I make Visual Studio use my database instead of the .mdf file located in App_Data folder in ASP.NET MVC project? 从Visual Studio 2012中的网站发布中排除文件夹而不是Web应用程序项目 - Exclude folder from Publish for a Website not a Web Application Project in Visual Studio 2012 如何在Visual Studio中发布类库? - How do you publish Class Libraries in Visual Studio? 如何使用ResX资源发布/部署MVC项目? - How do I publish/deploy an MVC Project with ResX Resources?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM