How to create NuGet package that add only JavaScript/CSS to web-based project?

前端 未结 2 477
借酒劲吻你
借酒劲吻你 2021-01-17 17:16

I have some NuGet package that contains both DLL file and web related files like JavaScript, Stylesheet and image files. I want to create package that only install web relat

相关标签:
2条回答
  • 2021-01-17 17:51

    You probably want to use the Nuget Package Explorer. It allows you to create a package without the command line and add only the required files to your package (plus some easy config).

    If I understand you correctly, you sometimes want to install just the DLL, and sometimes the DLL plus the web stuff. In this case it's best to create a separate package for the DLL, then another package with the web stuff which specifies the DLL package as a dependency of the Web package. This way it will automatically add the DLL when you add the Web content.

    Here's a tutorial on Nuget Package Explorer that will probably help you.

    0 讨论(0)
  • 2021-01-17 17:57

    I have a solution which I am using in several projects which works pretty nicely.

    Create a second .Assets project, which contains the Assets, and reference all the files as links in your project, and mark them as embedded resources.

    YourProject.Assets - contains the css/html/js/cshtml files YourProject - files included as links, marked as Embedded Resource

    Then include my EmbeddedResourceVirtualPathProvider Nuget package, and it will serve you assets from the Embedded Resources in YourProject.dll.

    If someones wants to override the resources, they can install the .Assets nuget package and they will be included in their project and served.

    0 讨论(0)
提交回复
热议问题