Search code examples
c#msbuildcsproj

understanding the content of a csproj file


I have some older projects in non-SDK style which were created using Visual Studio; the csproj files were almost never modified manually. They were done partly by colleages before I came to this company, so I have very incomplete knowledge about what should or shouldn't be in these files.

Now I am trying to turn them into SDK-style projects by manually modifying the csproj files. In order to do that, I need to understand for each tag what it is for, and if it can be omitted or must be modified.

There might be

  • non-SDK-style leftovers that can just be deleted,
  • content we were not aware of (because we don't always know what we are doing when playing around with settings in a project),
  • content that needs to be modified to fit the new SDK-style specification,
  • content that can be omitted because it contains just its default value,
  • etc.

I try getting by by googling a given tag together with "csproj", but more often than not I cannot find useful content. I also noticed that most of the time I DO NOT find a source from Microsoft, mostly blog entries by private guys that sometimes, sometimes not tell me what I want to know.

There are some Microsoft docs like sdk reference or common properties, but they do not cover all tags that I have in my project.

So, how can I understand the content of my csproj file? Is the documentation there and I am merely not finding it? If so, what to search for? Shouldn't Microsoft have a comprehensive list of all possible tags? They have invented the csproj format, so they should know. Or do I need to learn something else first that is a prerequisite of working with csproj files (like before constructing bridges one should know about basic algebra and calculus), that will help me figure out stuff on my own?


Solution

  • cproj files can have a lot of project configurations. Visual Studio Extensions might also modify cproj files and add custom values.

    As per the comments on this answer, there isn't a complete list of available properties for Visual Studio projects. The links provided in the question contains most used properties, so that should cater for the average project.

    It is very rare that properties will be used that is not contained in those links. If you do run across an unknown property, try searching online, if that fails, ask on SO.

    A good search query that hasn't failed me yet, {Project Type} "{Property}" csproj property : .Net "TestProjectType" csproj property.