I am developing a C# project in Visual Studio 2019. I've read that it should produce .csproj.user files automatically, but it is not. How do I force Visual Studio to produce a .csproj.user file? Thank you.
-
1Why "it should"? What do you want those files for? – Alejandro Jun 04 '21 at 18:11
-
In my case they seem to be needed https://stackoverflow.com/questions/69353503/controls-and-forms-missing-icon-and-view-designer-option-in-vs2019-running-sdk-p – Kirsten Oct 19 '21 at 05:31
-
1Strange question, it gets created when it *needs* to be created. Like Project > Properties > Debug tab, type something in the "Command line arguments" box and save the project. – Hans Passant Oct 19 '21 at 09:24
-
That is the answer. Care to write it up? – Kirsten Oct 23 '21 at 21:00
2 Answers
As mentioned by Hans Passant above, this file is created when there exist user-specific settings. Typically it is created by changing any of the Project->Properties->Debug settings to non-default values (i.e. specifying command line arguments or setting an absolute path for the working directory).
However, as I already have pointed out in the other question, I believe you should not commit this file and find out why you have problems without it. Or rather, why VS adds some relevant information to this file instead of the main csproj.

- 14,535
- 3
- 23
- 49
In my case strangely some references that should have been in the SDK project had found their way into the csproj.user file. I don't know why this happened. Once I put the references back in the SDK project I had no need for the csproj.user after all.

- 15,730
- 41
- 179
- 318