c# - .CSProj 和 .Sln 文件有什么用?

标签 c# asp.net visual-studio

<分区>

我搜索了很多有关 .csproj 和 .sln 的内容。我现在知道的是 .Csproj 文件包含有关项目的信息,而 .sln 文件包含有关解决方案中所有项目的信息。

我的问题是它们包含哪些信息,任何实际示例都会真正有帮助。

下面的说法对吗?

我们在 Web 应用程序中有 .csproj 而不是在网站中?

谢谢

最佳答案

Habib 所说的对您来说是最好的选择。当您打开 CSPROJ 或 SLN 文件时,您会发现一个 XML 文件(存储为文本),其中包含大量关于

的信息
  1. 如何构建项目及其设置。
  2. 项目引用的程序集。
  3. MSBuild 信息和命令:MSBuild 是一个框架,允许开发人员使用他们在 MSBuild 文件(例如项目文件本身)中指定的命令来自定义构建过程。例如,如果您希望项目在每次构建时以自定义方式处理文件,您可以使用 MSBuild 并将其放入您的 CSProject 文件中。

Web 项目有一个引用,也可以有自定义构建操作,这就是为什么应该有一个项目文件的原因。同样,这样的项目包含文件,项目文件列出了这些文件以及如何构建/编译它们。这与其他 IDE 中基于文件的项目不同,在 Visual Studio 中,您可以在项目文件夹中拥有属于该项目的文件。

关于您关于网站和 Web 项目的问题,这里有一个关于 Web Application Projects versus Web Site Projects in Visual Studio 的链接关于在网站中包含哪些文件(没有有项目文件),它说:

For web site projects, all files in a folder structure are automatically considered to be included in the web site. If you want to exclude something from compilation, you must remove the file from the web site project folder or change its file-name extension to an extension that is not compiled and is not served by IIS.

关于c# - .CSProj 和 .Sln 文件有什么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13152933/

相关文章:

c++ - Visual Studio 中的 Cuda 并行代码生成

c# - "ASP.global_asax does not exist in the namespace ASP"

C# 控制台程序,包含常量静态字段以在输出 main 方法中显示文本

c# - Xamarin AlarmManager Android

c# - 如何获取我试图在 IModelBinder 中绑定(bind)的参数的属性?

javascript - 不正确的 DOM 问题

c# - DateTime类常见错误再次显示

c++ - 使用 CMake 为 VS 2017 生成解决方案的问题

ASP.NET 应用程序针对 NHibernate 抛出 "unable to find assembly"错误

c++ - VS2013 : compiler bug with float and/EHa +/fp:strict?