Faisal
Faisal

Reputation: 119

Asp.Net MVC Core 3.1. why index.cshtml.g.cs added to the view folder and no error

Recently I started to notice that my project is adding views with xxx.chtml.g.cs. I tired to search for the answers within stackoverflow and other resources, and the answer I am getting that these files are generated due to some error. But for me there neither is no issue nor getting any compile error. This generated files have hardcoded obsolete path to the resources, and this is what my concern is, if I was working in a the team and other team member would pick up the code what if these files are to be used and won't find the resources on the path.
These files are added into the debug folder: MySolution\MyMVCProject\Debug\netcoreapp3.1\Razor\Views\Disenfection

If someone suggest me to delete the folder or tells me it won't effect then my question will be how I can keep my code clean and do not generate this unnecessary files. I am using asp.net MVC and VS 2019 community addition.

[Below is the xx.cshtml.g.cs file. it shows the hardcoded path.1

Upvotes: 0

Views: 1194

Answers (1)

Faisal
Faisal

Reputation: 119

I figured those files are auto generated files. I used Visual Studio 2019 and when checking codes. I went to each suspicious files, right clicked on it. If it said 'Local file ignore' I clicked on it and it was saved in .gitignore file. This way I was able to not check-in my code.

Upvotes: 1

Related Questions