SolvedHome contentFiles (cs, compile) not working in NetStandard projects.

Hi, I run LibLog - a source code logging package for library developers. I am failing to achieve NetStandard support ( damianh/LibLog#125 )

I was unsure whether to log issue here or dotnet/sdk. I'm following https://twitter.com/davkean/status/841619178050150405 advice.

Details about Problem

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): Package Manager Console

NuGet version (x.x.x.xxx): 4.0.0

dotnet.exe --version (if appropriate):

VS version (if appropriate): 2017

OS version (i.e. win10 v1607 (14393.321)): 10.0.14393 Build 14393

Detailed repro steps so we can see the same problem

  1. Checkout this branch https://github.com/damianh/LibLog/tree/loqu8-netstandard
  2. To build a nuget package, run .\build.ps1. This will put a package in build directory
  3. Open the solution src\ContentFilesTest\ContentFilesTest.sln in VS2017. You will see two projects that don't compile where we will install LibLog.
  4. In Package Manager Console, select the project DotNetFramework46 and install LibLog: install-package LibLog -prelease -source ../../build/ . LibLog should be installed into the project DotNetFramework46, visible in folder App_Packages\... and that project should now compile.
  5. In Package Manager Console, select the project DotNetStandard and install LibLog: install-package LibLog -prelease -source ../../build/. The project DotNetStandard continues to not compile and the type LogProvider cannot be resolved.

Other suggested things

There is more information in the comments in the related issue damianh/LibLog#125 , including the fact that no transformed file is written to obj\Debug\...

Verbose Logs

damianh/LibLog#125 (comment)

Sample Project

Let me know if you want a zip of the project instead of checking out the branch.

32 Answers

✔️Accepted Answer

@emgarten Thanks for your fantastic support.

Two suggestions.

  1. Please provide docs! NuGet is essential for .NET/.NET Core development. Imagine how many developers struggle when it comes to more advanced things like content files, install scripts, build props and targets. There is almost no documentation out there. We have to read through blogs, outdated docs or ask you guys stupid questions. What a waste of time! Our time and your time. We need maybe 20 pages of in-depth coverage. That's all. Buy me a beer and I'll do it for you.
  2. Add a TFM for libraries that can only be executed in .NET Core over full Framework environments. In the past you had these TFMs like dnx* or netcore*. If we have a library that can only run on .NET Core over full Framework we cannot just put it in a lib/net* folder because it could be imported into traditional projects. Why not just reactivate netcore* (preferred) or maybe add an attribute like this?
     <dependencies>
       <group targetFramework=".NETFramework4.6" netcore="true"> 
         <dependency id="SomeLibrary" version="1.0.0" /> 
       </group> 
     </dependencies> 

Other Answers:

Come on NuGet guy's. This problem has been reported at least one year ago. ContentFiles did not work in project.json and also do not work in the new csproj based projects. We need at least a way to copy additional assets to the project. This can't be too hard.