简体   繁体   English

我应该在 ASP.Net Core Web 应用程序中提交我的 wwwroot/lib 文件夹吗

[英]Should I commit my wwwroot/lib folder in ASP .Net Core Web Application

I've just created an ASP.Net Web Application using the dotnet new webapp command.我刚刚使用dotnet new webapp命令创建了一个 ASP.Net Web 应用程序。

I wonder if I the wwwroot/lib folder should be committed?我想知道我是否应该提交wwwroot/lib文件夹? It looks like it contains versioned libraries and the version is not mentioned anywhere else in the application, so I think I should commit them.看起来它包含版本化库,并且在应用程序的其他任何地方都没有提到该版本,所以我认为我应该提交它们。 But I really don't want to have distributions of 3rd party libraries in my git repository.但我真的不想在我的 git 存储库中分发 3rd 方库。

If your team has negotiated which libraries to use and their versions are clear, you can write the list of libraries to the readme to remind other members.如果您的团队已经协商好使用哪些库并且它们的版本明确,您可以将库列表写入自述文件以提醒其他成员。

If the referenced library is not large and you want to better ensure the integrity of the code, you can commit wwwroot/lib.如果引用的库不大,想更好的保证代码的完整性,可以commit wwwroot/lib。

With recent changes in ASP.Net core web application.随着最近 ASP.Net 核心 web 应用程序的变化。 you can choose to ignore adding client side lib (content of wwwroot folder) in your version control such as git.您可以选择忽略在版本控制中添加客户端库(wwwroot 文件夹的内容),例如 git。

they need to be restored during build.它们需要在构建过程中恢复。

you can use LibMan to restore those libraries during build.您可以在构建过程中使用LibMan来恢复这些库。

this article from microsoft will guide you how to enable restoring client side library during build so that you don't have to add them to your version control. 这篇来自 microsoft 的文章将指导您如何在构建期间启用恢复客户端库,这样您就不必将它们添加到您的版本控制中。

since it also contains the specific version so that there will not be any compatibility issues.因为它还包含特定版本,所以不会有任何兼容性问题。

example libman.json file示例 libman.json 文件

 {
  "version": "1.0",
  "defaultProvider": "cdnjs",
  "libraries": [
    {
      "library": "jquery@3.3.1",
      "files": [
        "jquery.min.js",
        "jquery.js",
        "jquery.min.map"
      ],
      "destination": "wwwroot/lib/jquery/"
    },
    {
      "provider": "unpkg",
      "library": "bootstrap@4.1.3",
      "destination": "wwwroot/lib/bootstrap/"
    },
    {
      "provider": "filesystem",
      "library": "C:\\temp\\lodash\\",
      "files": [
        "lodash.js",
        "lodash.min.js"
      ],
      "destination": "wwwroot/lib/lodash/"
    }
  ]
}

Hope this helpful.希望这有帮助。

The decision is a trade-off between build time vs having "restorable" files in a repo.该决定是构建时间与在存储库中具有“可恢复”文件之间的权衡。 In few projects, initially I ignored files under wwwroot/lib and used libman.json and restoring the client libraries at build time .在少数项目中,最初我忽略了 wwwroot/lib 下的文件并使用 libman.json 并在构建时恢复客户端库 This restore had an impact on the "free minutes" provided by CI (Github Actions, Azure DevOps), so I reverted my decision;这次恢复对 CI 提供的“免费分钟”有影响(Github Actions,Azure DevOps),所以我恢复了我的决定; and manually restored those files and pushed the wwwroot/lib files to repo.手动恢复这些文件并将 wwwroot/lib 文件推送到 repo。

If the free build minutes is not a constraint, I would recommend not to store the files in the source control如果免费构建分钟不是限制,我建议不要将文件存储在源代码管理中

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

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