-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
contentFiles (cs, compile) not working in NetStandard projects. #4803
Comments
Packages.config projects use the In your steps the DotNetFramework46 project ends up being a packages.config project which does not use the To allow your package to work in both types of projects you should put the pp file in both places. The reason for this is that older packages.config projects require Visual Studio to install packages, and items from the |
Thanks or the response @emgarten , however I'm not grokking what I should actually do.
It is as far as I can see... if not what changes are need to https://github.com/damianh/LibLog/pull/125/files#diff-6ec70a9e9835da1a3387257b2d950192R36 to make this work? Cheers. |
Try this |
@tofutim I'll respond on damianh/LibLog#125 |
@damianh you need to have the files under both |
@emgarten Like this?
|
Unfortunately this statement is confusing me:
Honestly a working nuspec would be much easier to move forward on. |
... did not work. |
Files at the root of contentFiles are not picked up. You need to have:
Your nuspec contentFiles section has |
Applied your suggest (please correct if wrong). Doesn't appear to work.
|
@damianh take a look at https://www.nuget.org/packages/ContentFilesExample/ |
@emgarten Thank you very much for that package! However, I've been testing it and there seems to be a number of issues. I hope the problem is me :( 1. Installing the package doesn't show the content files as part of the project:Closing and re-opening the solution subsequently shows the content files: 2. The files
|
Thanks for the details @damianh @natidea has anything changed with .pp files? I tried also and didn't see them getting generated in VS 2017 RTM but I do see them in project.assets.json. Related: dotnet/sdk#70 The delay in adding/removing the files from Solution Explorer looks like a VS issue, I see them written out correctly to the obj props file. |
I was also able to reproduce the same issues @damianh mentioned above when trying to use the |
I am relieved that it has been repro'd. Thanks guys. |
@emgarten @natidea Gents, any update or thoughts on this? It appears that source transforms are completely broken. LiteGuard is another project that is affected. cc @adamralph |
LiteGuard, due to it's simplicity, is also a great test-bed for new/changed tooling. I've used it personally as my "hello world" for learning about PCL's, multi-targetting, project.json, etc. etc., with the benefit that it's also a real package, with real users. I'd be more than happy to use LiteGuard to help smoke test any work that comes out of this issue, from a package producer POV, . |
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. |
@blackcity this issue is currently narrowed down to .pp files not being transformed for NETCore projects. If you are unable to get contentFiles to work at all then you may have a package that is authored incorrectly. Would you own a new issue explaining the issues you are currently seeing along with repro steps and a copy of the package that doesn't work? |
It is exactly like described in this post:
For our packages it is important that the content files (assets) are copied to the solution, not just referenced. With the package we need to copy config files (XML files) the developer wants to change. This was standard in the packages.config era. We cannot publish a package with this strange behaviour without our customers killing us. Btw: Just tested again with ASP.NET Core Project (.NetCoreApp1.1) and the package mentioned above: https://www.nuget.org/packages/ContentFilesExample/ |
This is not supported with project.json/PackageReference. With packages.config users had to run install and uninstall commands explicitly and this was done through Visual Studio. With project.json/PackageReference packages can float which allows them to change from restore to restore without an explicit install/uninstall action being performed. For this reason the The plan going forward for this is to allow users to move files from under the My suggestion for copying config XML files to the user project is to handle this in an |
Thanks @emgarten for this detailed answer. So init.ps1 and and targets work in ASP.NET Core projects (csproj)? |
Yes, if installed using Visual Studio init.ps1 will be executed. This works on all types of projects. The script will also run when opening the solution if the nuget powershell console is open. If someone manually edits the csproj outside of Visual Studio and restores then it will not run, but you could catch this scenario in a targets file where the config is missing and fail the build with a helpful message. |
Sorry just getting to this after my vacation. I took a look at the pp file transformation issue and found a couple of things:
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> Now I can use the So somewhere along the way, some concepts may have been crossed. We default Adding @livarcocc and @dsplaisted from SDK who would need to resolve this. |
I should have mentioned, I had to modify |
@emgarten This seems to work now. We are using init.ps1, build props and targets. lib net45 library.dll // for traditional Framework net461 library.dll // for ASP.NET Core (full Framework) netstandard1.6 library.dll // for ASP.NET Core The net461 library can only run in ASP.NET Core projects (the full Framework). Is there any way to prevent traditional projects from referencing the net461 TFM and instead reference the net45 assembly? |
NuGet will take the highest compatible asset. If the project is net462 for example it will take net461. If the project is net46 it will use net45 since net461 is not compatible. If you use a targets file in the package instead of the lib folder you can select the dll based on other project properties instead. |
Great answer thanks. Really last question: What if the project is net462 and the NuGet package provides TFM for netstandard1.5 and net461. Does the project choose the netstandard1.5 library because it is the highest compatible TFM or does it choose net461 because it is more specific. |
If the project is |
@emgarten Thanks for your fantastic support. Two suggestions.
<dependencies> <group targetFramework=".NETFramework4.6" netcore="true"> <dependency id="SomeLibrary" version="1.0.0" /> </group> </dependencies> |
Moving this to dotnet/sdk#1100 The issue here appears to be in the SDK. I see the correct outputs from NuGet. |
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
.\build.ps1
. This will put a package inbuild
directorysrc\ContentFilesTest\ContentFilesTest.sln
in VS2017. You will see two projects that don't compile where we will install LibLog.DotNetFramework46
and install LibLog:install-package LibLog -prelease -source ../../build/
. LibLog should be installed into the projectDotNetFramework46
, visible in folderApp_Packages\...
and that project should now compile.DotNetStandard
and install LibLog:install-package LibLog -prelease -source ../../build/
. The projectDotNetStandard
continues to not compile and the typeLogProvider
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.
The text was updated successfully, but these errors were encountered: