Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the use of .CSProj and .Sln file? [closed]

i searched a lot about .csproj and .sln. What i know now is .Csproj file contain info ab projects and .sln file contains info ab all the Projects in the solution.

My Question is what info does they contain any practical examples will really help.

And also is the below statement right ?

We have .csproj in Web application not in website ?

Thanks

like image 888
Peru Avatar asked Oct 31 '12 07:10

Peru


People also ask

What is the use of .sln file?

sln file. The . sln file contains text-based information the environment uses to find and load the name-value parameters for the persisted data and the project VSPackages it references. When a user opens a solution, the environment cycles through the preSolution , Project , and postSolution information in the .

What is the purpose of the .csproj file?

csproj file tells dotnet how to build the ASP.NET application. It's one of the most important files in an ASP.NET project. An ASP.NET project can depend on third-party libraries developed by other developers. Usually, these libraries are installed as Nuget packages using Nuget package manager.

Is sln file necessary?

As far as I'm aware, the SLN is a 100% Visual Studio Tooling concept. You can still create applications, run/compile/publish them without this file. That's how Visual Studio Code does it and that's how you would do it in Sublime/Atom or any other editors.

How do I open a .csproj file?

Start from a project If your program code is already in a Visual Studio project, open the project. To do so, you can double-click or tap on the . csproj file in Windows File Explorer, or choose Open a project in Visual Studio, browse to find the . csproj file, and select the file.


2 Answers

What Habib said is the best thing for you to do. When you open a CSPROJ or SLN file you will find an XML file (stored as TEXT) with lots of information about

  1. how to build a project and its settings.
  2. the assemblies that the project references.
  3. MSBuild information and commands: MSBuild is a framework to allow a developer to customize the build process using commands that they specify in MSBuild files such as the project files themselves. For example if you want the project to process files in a custom way everytime you build, you use MSBuild and you can put this in your CSProject file.

A web project has a references and also could have custom build operations, this is why there should be a project file for it. Also such a project contains files and the project file lists those files and how to build/compile them. This is unlike file based projects in other IDEs, in Visual Studio you can have files in the project folder that do not belong to the project.

Regarding your question about Websites and Web projects here's a link about Web Application Projects versus Web Site Projects in Visual Studio and regarding the inclusion of what files in a website (that don't have a project file) it says:

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.

like image 133
Mzn Avatar answered Sep 25 '22 01:09

Mzn


For the Solution (.sln) file contents, you can find a lot of information on this MSDN article.

Concerning the Project (.csproj) file contents, here is another MSDN article that describes what's inside a C++ Visual Studio 2012 project, which is very close to a C# project, and here is an introduction to Projects with Visual Studio 2012.

like image 27
Yannick Blondeau Avatar answered Sep 26 '22 01:09

Yannick Blondeau