-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Installing NLog.Config and NLog.Schema in a .NET Core project in Visual Studio 15.7.x and/or NuGet 4.7.x does not copy the files in the project root #2823
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
Comments
Hi, having the same issue with dotnet core 2.1 project (NLog.Schema 4.5.7, tested same issue with 4.5.6 too). |
Thanks for the info. Unfortunately, I had no time to check this. Does anyone has an idea what needs to be changed in the nuspec to get this working? |
@304NotModified did some googling and it seems that this is not a NLog nuspec issue but the new way how packagereferences work. Simply put, you can't copy files anymore to project. There are plenty of "issues" about this but I think this is a good one to follow in case something changes as the last posters have the exactly same issue not being able to copy XSD file for intellisense: NuGet/Home#4942 This one suggests to use init.ps1 to copy the file to project: NuGet/Home#4803 (comment) And this one says copy it manually: NuGet/Home#4954 (comment) |
That's what I feared. I don't know how much the
it's certainly better than nothing, but it can lead to users complaining that "it's not working" if they're not installing the packages "by the book". Maybe a warning can be added to the package description and the wiki? The MSBuild .target option is unfeasible since it works only at build time and we need the files at design time. So...
|
We've added the "contentFiles" for that a while ago. see
Don't know why that isn't working anymore. To summarize the history in NLog:
maybe we should re-order the stuff in current: NLog/src/NuGet/NLog.Config/NLog.Config.nuspec Lines 29 to 33 in b728a6d
|
Because it never worked: the In emgarten's words:
(Whatever that means, I still haven't found out what "floating" means.) By the way, the |
i was confused by init.ps1 and install.ps1. update #2823 (comment)
I personally tested it in .NET Core 2. It worked. So i'm confused now |
The problem is caused by the installation method used: the To demonstrate this, I tried to install the following NLog.Config packages on the following .NET Core projects:
As you can see no combination worked, even the one that previously did. I don't know if it's Visual Studio's or NuGet's fault, they're not exactly clear with their release notes, but I think that using The problem is I don't have any mean to test this out besides firing up a virtual machine and installing the old versions of VS which would be... slightly time consuming, it possible at all (their site only has the latest version available to download). Also, while performing the tests, I noticed another possible issue: in the Tutorial wiki page there's this bit:
At the moment, .NET Framework (not .NET Core) projects still use the Works out of the box: However if the user has upgraded the project, it doesn't: Here no file at all is added to the project, even the linked ones. Also, if someone using .NET Core follows this tutorial (I know there's one dedicated to .NET Core but, y'know, users be users) it's messy too: |
thanks for checking this. Is it clear what needs to be changed? |
From what I've read around - mainly what has already been linked in this thread - you simply no longer can do this. The new version simply does not allow a package creator to add a per-project physical file to a project when a package is installed, only to add a symlink to a single unique instance of a file located in the NuGet package cache directory, and Microsoft won't do anything about this because it's working as intended. This means that the NLog.Config package has become useless for users using the new version, since the same physical file will be shared between all the projects where the package is installed and every change will be seen by every project. The NLog.Schema may still has some use, because since a user shouldn't ever modify the XSD having a single instance shouldn't cause any problem. However, I noticed that when the package gets installed due to a dependency (e.g. by installing NLog.Config) the XSD file is not linked, it gets linked only when the package is installed directly. I have no idea why this happens and what can be done to fix it, my NuGet skill are limited. |
@304NotModified Instead of using the https://github.com/SaganMarketing/NuGetContentFiles/tree/master/TestParent/TestParent
See also: NuGet/Home#6743 |
If someone could "hack" a PR for this, that would be really great 💯 |
Not using NLog.config, so I will pass that chance :) |
This might be a good inspiration for making the missing targets-file: |
Neither this nor the previous suggestion will work. These solutions are for copying files at build time, however both the XML and the XSD are needed at design time, because the user must be able to edit the configuration file before building/deploying the application. Having a blank configuration file copied to the output directory is useless. And what we need, unless something changes in the future, is no longer possible in the new NuGet package architecture. |
Can't we just close this and agree that things have changed and this can't be done anymore. The workaround is to get the XSD file somewhere and manually copy it to the desired location. |
I am experiencing the behavior that @kappa7194 describes while using This looks like only a "cosmetic" issue as:
Not sure it is a good idea to keep the |
You can get the XSD file to be available (not editable) at design time by also sending it to buildcrosstargeting as well as build folder. That makes it get seen by the VS design time build. I've used it and it was used by the sourcelink project see this commit |
I used an external directory like Logs to place my NLog.config file and then load it from Main class.
|
@304NotModified Do you need a hand fixing this, or are you in the process of fixing this already? :) |
That answers my question i guess. meh. |
Maybe we could try #2823 (comment), but I haven't found time for that. |
@304NotModified That sounds potentially dangerous if it does not provide versioned files and would allow invalid options for the xsd. What about injecting inline contents from ps1 itself?. |
Not sure if that's a problem, we could version the XSD files (just like now they are version in the nuget package) But inline could also work, maybe even better! |
Seems to me that with #4322 it's been decided to drop support for this NLog.config nuget package altogether. On the nuget page: It still says
But the link is now broken, naturally. I would have suggested to link to a tagged version instead: https://raw.githubusercontent.com/NLog/NLog/v4.7.9/src/NuGet/NLog.Config/content/NLog.config but I guess it's kind of moot. Cheers |
Yes the package will be removed with nlog 5 Thanks for reporting the dead link! |
Thank you for reporting this. Will try and restore the link, so it will stay alive a little longer (until being deleted by accident again)
|
Update: The issue seems to be tied to the version of Visual Studio and/or NuGet too, see below.
How to reproduce the problem
Add the NLog, NLog.Config and NLog.Schema packages to a .NET Core 2.1 Console Application project.
Expected behaviour
The XML and XSD files from NLog.Config and NLog.Schema are copied in the project root.
Actual behaviour
The files are not copied to the project root, instead they are somehow "virtually linked" there (there's no "link" at file system level) from the NuGet packages cache directories.
Why this is a problem
The first problem is especially nasty since it affects every projects that is using the packages, and there's absolutely no warning about it.
Related issues
#2461, #2686, #2757
Maybe related to https://docs.microsoft.com/en-us/nuget/reference/migrate-packages-config-to-package-reference#package-compatibility-issues as suggested in #2757.
Platforms
Packages versions
Screenshots
Installing the packages adds "virtual files":
The files are "linked" from the NuGet packages cache:
The packages have been added through PackageReference:
The files are not copied in the project root:
IntelliSense will not pick up the XSD schema, and the XML file is shared between every project:
(The XML file in the screenshot has not been yet modified in this project, yet its content is not the default one but the modified one from another project.)
The text was updated successfully, but these errors were encountered: