11

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 related file to web project only (including ASP.NET and ASP.NET MVC project). What is the easiest way to do that?

Thanks,

PS. I think it should be possible via Powershell script. But I think, it is quite complex for me.

  • Why don't you want to include the dll into the web project? What are you packaing? Does it make sense to have 2 packages? – davidfowl Nov 28 '11 at 06:18
  • Please read my question carefully. I need to install only DLL to other like class library. In the other hand, I need to install both DLL and web related file (including JS and CSS) to web project like ASP.NET website or ASP.NET MVC. –  Nov 29 '11 at 10:36
  • You're probably going to need to learn a bit of PowerShell. – CoderDennis Dec 05 '11 at 02:27
  • Currently, I decide to move dll into main package and use another package for web-related files only. However, this way doesn't solve problem for long term development. –  Dec 05 '11 at 17:08
  • See this answer https://stackoverflow.com/a/76538608/6259522 – eharbitz Jun 23 '23 at 09:09

2 Answers2

12

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.

Kols
  • 3,641
  • 2
  • 34
  • 42
avesse
  • 771
  • 1
  • 9
  • 20
0

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.

mcintyre321
  • 12,996
  • 8
  • 66
  • 103
  • It isn't normal way to deploy JavaScript or image file in NuGet package because web server cannot optimize for this kind of resource. But this solution might works for some package that doesn't want to add any other file to deployed project rather than their dll. –  Feb 07 '13 at 11:53