1

I have a .NET Core 2 application and I'm trying to reference a NuGet package which contains static files and have them copied to my application similarly to how the "content" directory worked in the past.

According to the following https://blog.nuget.org/20160126/nuget-contentFiles-demystified.html this looks to be supported under a "contentFiles" directory.

I've found the following package which looks to support the new schema:

https://www.nuget.org/packages/ContentFilesExample/

And added a reference to it by adding the following to my .csproj file:

<PackageReference Include="ContentFilesExample" Version="1.0.2" />

Now when I run dotnet restore it doesn't copy anything to my application. I've been searching through the GitHub issues but it's hard to follow what is outdated and what is supported.

I'd appreciate it if someone could let me know if this is supported and what I could possibly be doing wrong. If it's not supported please could you point me in the direction of the correct GitHub issue to follow. Thanks

nfplee
  • 7,643
  • 12
  • 63
  • 124
  • What is the point of keeping the Nuget package with this problem a secret?? – Hans Passant Nov 08 '17 at 13:23
  • I haven't created a NuGet package yet. I'm exploring how I can upgrade a modular ASP.NET MVC 5 to ASP.NET Core. The NuGet package specified is a good example of what I'm trying to achieve. – nfplee Nov 08 '17 at 13:50

2 Answers2

4

With PackageReference, the files are never copied over to the project. Rather the content files live in the global packages folder as immutable entities. You can still refer to these files as if these were expanded in your project. If you use Visual Studio 2017, you can see these as refs as shown below. You can refer to .csproj.nuget.g.props file in the obj directory to find out the details of the files refs/links.

Anand Gaurav
  • 224
  • 1
  • 4
  • Thanks Anand. I had originally been using Visual Studio Code so I didn't see the ref/link files. I also found https://stackoverflow.com/a/30386836/155899 which helped aswell. – nfplee Nov 10 '17 at 22:06
-1

Have you looked at NuGet pkg Microsoft.AspNetCore.StaticFiles (2.0.0) ?

programmerj
  • 1,634
  • 18
  • 29
  • This package allows me to use static files that are within my application. The problem I have is that the static files are not copying to my application when it installs a NuGet package which contains static files. – nfplee Nov 08 '17 at 16:01