What is GUID for Visual Studio projects

Asked

Viewed 257 times

3

I have a "base" project in C# MVC (login, access control and related), to replicate in other projects, which consists of copying the fonts and sometimes renaming the project.

Do I have to change the Assembly GUID? What’s it for? Have a problem having 2 projects with the same GUID?

  • It might be interesting to create a project template instead of copying and renaming. Decreases effort and chances of error.

1 answer

3


If you copy the project for another Solution, no problem. Visual Studio uses these Guids to manage references/dependencies between projects. This is an example of the GUID:

<ProjectGuid>{0186C50F-7FBA-43D1-B403-D8BE75193671}</ProjectGuid>

If you try add (instead of copying) a project with a repeated GUID in a Solution, Visual Studio will automatically generate a new GUID for that project.

The same occurs if you try to make one Unload of the project (by Visual Studio), edit the .csproj and try to change the project’s GUID by placing a repeat (on Solution). When doing Reload, Visual Studio will take the GUID that Solution (.sln) has for the project, and overwrite it.

If you try to edit your own .sln trying to force multiple projects to have the same GUID, when opening Visual Studio, it will automatically generate new Guids for duplicates.

This can be a problem if you use the same project in different Solutions, because if for any of the above reasons Visual Studio generate a new GUID for a project, when opening it in another Solution can give reference/dependency problems.

One way to solve this (in case you need to have the same project in different Solutions) is to make both Solutions use the same GUID for the shared project, so they won’t be overwriting each other’s GUID in the file .csproj. But this is a matter of preference, I understand that each form has pros and cons, it is necessary to analyze how you or your team prefer to work.

That is explained here (it is in English, however).

Some projects also contain the GUID below:

<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

As is the case with Webapplication, that simply causes Visual Studio to open different menu options for the project.


I have particularly tried to use shared projects in different Solutions, but I ended up opting for something different. When I have a project that would like to have the source shared with other Solutions, I create a Nuget package and publish it in one package source internal, and install it in projects where I need to use it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.