简体   繁体   English

github 中的 asp.net 核心 appsettings.json

[英]asp.net core appsettings.json in github

I have a couple of projects built using ASP.NET Core 3 which I develop on localhost and publish to my shared Windows hosting account.我有几个使用 ASP.NET Core 3 构建的项目,我在本地主机上开发并发布到我的共享 Windows 托管帐户。

I want to put the above mentioned projects into GitHub in Public repositiories, but the problem is the appsettings.json file has the connection to the SQL Server database that is on the shared hosting.我想将上述项目放入公共存储库中的 GitHub,但问题是 appsettings.json 文件连接到共享主机上的 SQL Server 数据库。

Is there any way to get around this information showing in appsettings.json when pushed to GitHub?当推送到 GitHub 时,有没有办法绕过 appsettings.json 中显示的这些信息?

I have read about using Secrets in appsettings.json but I don't think I could use the Secrets on the shared Windows hosting (unless I am missing something obvious there).我已经阅读了关于在 appsettings.json 中使用 Secrets 的内容,但我认为我不能在共享的 Windows 主机上使用 Secrets(除非我在那里遗漏了一些明显的东西)。

Any help greatly appreciated!非常感谢任何帮助!

Thanks in advance.提前致谢。

If you are not able to use environment specific configuration, like environment variables or the secret manager (see the docs ), you can create an own repository for deployment which contains the production appsettings file (containing sensitive information like the connection string).如果您无法使用特定于环境的配置,例如环境变量或秘密管理器(请参阅文档),您可以创建自己的部署存储库,其中包含生产 appsettings 文件(包含连接字符串等敏感信息)。 You could push to both repositories, or keep the repositories in sync automatically eg using GitLab's Repository mirroring (if hosting the private repositories there is an option).您可以推送到两个存储库,或者自动保持存储库同步,例如使用GitLab 的存储库镜像(如果托管私有存储库,则有一个选项)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM