Home > Back-end >  Is there a way to manually trigger Visual Studio to update .csproj files?
Is there a way to manually trigger Visual Studio to update .csproj files?

Time:09-21

I sometimes lose my pending changes to the .csproj file. I'm left with a changeset of new files, which still carry the appended [add] tag in the Team Explorer, but pending updates to the .csproj file are wiped out.

I can manually edit the .csproj to add them, but this is tedious and error-prone. Is there a way to re-run whatever process normally updates the .csproj file automatically?

CodePudding user response:

Normally, changes to .csproj files should be very rare, when using the new SDK style projects.

Since by default, all .cs files are included, you do not normally need any update to the project file if files are added or removed. So I suggest you remove all <Compile Add/Include/Update /> lines that refer to code as well as the line that says <EnableDefaultCompileItems>false</EnableDefaultCompileItems> if you have that.

For most projects that works just fine. It will reduce the frequency of changes to the project file significantly (and make it a lot easier to read).

  • Related