Hi @Ihor Kuliiev ,
I am going to create a Nuget package to use within our organization's ASP.NET applications. I need to find out whether it is possible to automatically add some lines of code into the Startup.cs file and a new section into the appsettings.json file once the package is installed.
It is not possible. As we all known, a Nuget package contains compiled code (as DLLs) along with other content needed in the projects that consume these packages. Before the Nuget package publish to the nuget.org, it has been compiled. So, when installed them, it will not update the Startup.cs file and the Appsettings.json file.
And most importantly, this is not safe to automatically modify the configuration when installed the package.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion