Should I commit my wwwroot/lib folder in ASP .Net Core Web Application
Asked Answered
P

3

6

I've just created an ASP .Net Web Application using the dotnet new webapp command.

I wonder if I the wwwroot/lib folder should be committed? 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.

Pierides answered 21/12, 2020 at 18:26 Comment(2)
dotnet new mvc comes with 57 files, totalling 7.8MB in the wwwroot/lib folder, but without a package management system to pull them in if they're not part of the repo. Feels weird to commit that many 3rd party files and add them to your own version control.Cope
The other trade-off that no one mentioned before(And I have been bit by this before) is when any of those libraries become unavailable or you need to run a very old build using much older framework/library versions and those libraries can't be downloaded or built/compiled with newer versions of framework and available native headers/compilers.Diphthongize
H
9

With recent changes in ASP.Net core web application. you can choose to ignore adding client side lib (content of wwwroot folder) in your version control such as git.

they need to be restored during build.

you can use LibMan to restore those libraries during build.

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.

since it also contains the specific version so that there will not be any compatibility issues.

example libman.json file

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

Hope this helpful.

Hermitage answered 25/6, 2022 at 9:12 Comment(3)
I've been using Libman for years. Recently, there have been some hiccups resulting in unavailalbe packges. In one of my projects, I even decided to remove Libman and put every dependency into a version controlled lib-raw folder where I pin specific versions of dependencies.Jug
@Jug Just curious, how do you manage them in the project? Also which tool do you use to manage it?Woolgrower
@Woolgrower We use Git for version controlJug
E
5

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.

Eudo answered 22/12, 2020 at 2:18 Comment(0)
P
3

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. This restore had an impact on the "free minutes" provided by CI (Github Actions, Azure DevOps), so I reverted my decision; and manually restored those files and pushed the wwwroot/lib files to repo.

If the free build minutes is not a constraint, I would recommend not to store the files in the source control

Pullulate answered 26/6, 2022 at 12:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.