-
Notifications
You must be signed in to change notification settings - Fork 258
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
After enabling PackageReference support for projects, some packages may not install or work correctly #4942
Comments
Any new from nuget team about files set as content with packagereferences? |
@cazzoo Can you please clarify what you mean? contentFiles are static are static and do not pollute the project directory, but they can still be part of the build/publish steps. |
@nkolev92 Thank you for the reference. I'll try to use that on a fork of a package that currently uses a ps1 file to copy an exe next to the build. Does that sound good to you? |
@cazzoo |
Hi guys. I want to ask if there is a way to support adding a content file with Package Reference to a project but adding it as a "link" to the target project file. I used to do that with the "install.ps1" and "uninstall.ps1" scripts, but it seems they are not supported in Package Reference mode. Here is what I actually want to achieve: Linking a file from a NuGet package |
@metatem https://docs.microsoft.com/en-us/nuget/reference/nuspec#optional-metadata-elements You'd have something like
in your package. And then in the nuspec you can specify the copyToOutput and build action metadata. |
@nkolev92 You mention
I'm curious to know how I would define a file to be used in a web project (let's say a branding image to use the same example as https://blog.nuget.org/20160126/nuget-contentFiles-demystified.html) where I want the image to be output somewhere in my project's file structure (let's say an Sorry if this is not the best place to ask the question, but I have a hard time finding any information about this in the documentation. |
@dee-see If you absolutely have to do that, the copying of those files is only achievable at build time using build targets as mentioned above. |
@nkolev92 How are you planning to migrate that to PackageReference? |
@dee-see I think that package would be simple to move to PackageReference, simply by moving all content to contentFiles. There are some gaps with ASP.NET full framework projects support for PackageReference that we're looking to address soon. |
@nkolev92 Wouldn't it just put the files in the publish directory's bin through? Without respecting the original hierarchy? |
So all packages relying on install.ps1 are broken "by design" (to name a few: #3656, #4318, #4876, #6330) with no meaningful way to upgrade... Upgrade/migration guidelines (#5963) have never arrived either. We are essentially put in a situation where there is no way forward, and the Nuget team is taking a stance "it is not supported, sucks to be you". That's just not good enough. |
Here is a scenario that is now broken. I have a nuget package that contains an xml schema (.xsd) in the content folder. The intent was that this schema would be copied into the VS project that consumes the package, allowing xml intellisense to "light up" when editing xml documents of that particular schema. VS only seems to discover .xsd files in the project or in the xml schemas folder down under the VS install folder (which isn't an option for nuget packages). If nuget/VS could be enhanced to allow shipping xsd in nuget packages, that would be ideal. I don't really want to copy the xsd into the project, I just want intellisense to light up. |
I have the same scenario described by @MarkPflug, and would love to have a better alternative for providing Intellisense, other than copying the Copying files to a project in general is really useful as it allows us to provide code templates within the NuGet package, that can be used as a starting point, right after the user installs the package. We need the content files in the |
Same issue. Please fix this. We (NLog) got multiple complaints because it's broken... also please stop making breaking changes in non-major versions. |
We have in our company a scenario where we need to copy a json file to the root folder with some default configuration for our library. I I can create the package with the file contents, libraries and stuff... but when installing the nuget package they never get copied to the root folder. Im using .net standard 2.0 class library |
RE: non \bin targeted files...
Well @nkolev92, nuget is a tool that delivers packages to other developers to lessen work or improve quality of their output. Its incredibly useful when you need to provide things like T4 templates for code generation in a package, or to have the package add/remove its needed entries in the .config file via XDT. With the install.ps1, I can handle all the things I need to manipulate in a project to ease development that NuGet or the project systems do not normally permit like non XDT configuration manipulation or adding files with a BuildAction of AdditionalFiles instead of Content.. Another person here mentioned branding;. With the death of Bower, we could have counted on using a NuGet package with CSS, script, and images to provide a common look and feel when we build a website for a customer. (Don't bother mentioning the replacement, I dont want or really need yet another package manager. I also have no interest or idea in learning how to make an NPM package for .net projects work) Where nuget is headed means we cant do any of those things, and all of the reasons and restrictions I've seen over the past year seem to stem from the idea that nuget.org is the only package repository or that all package repositories are public. If you dont want install.ps1 to be abused by "evil" package authors, then ban the install.ps1 scripts from being included in packages submitted to nuget.org. Offer the feature in Nuget.Server to also prevent them. Don't take a tool away from everyone else just because you are concerned that they will run amok in your house with it. If you don't like content files (content files or contentFiles) "polluting" projects, then give the consumer the choice at install time. Making that choice for them like this removes a sizeable part of the usability of nuget, and nuget needs to remain a tool that is useful or people will stop using it. |
@304NotModified |
See this excellent post: NLog/NLog#2823 (comment) |
@StingyJack you can use a msbuild .targets or .props file in your package to include files in the package folder in the consuming project. They won't show up in VS due to being in an imported file. <?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)\..\content\foo.cs"/>
</ItemGroup>
</Project> if you have content/foo.css that you want to include as AdditionalFiles <?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)\..\content\foo.css"/>
</ItemGroup>
</Project> There is probably a metadata you can add to the item to make it appear in VS but I don't know what it is. |
How to config for new project file to install content file for project? I use the code below, you can find the source here:
it works for .net framework apps, but it can not work for .net core apps ----------- Update ---------------------------- I'm using the code below, it seemed works on .net core but a little strange.
it can not work for netfx project with packagereference, and for .net core project it generated an log4net item that links to the package file like |
@ticktickMOF - I would think that CSS would be a Content file instead of an AdditionalFile so it gets published correctly. @rrelyea - Can you point to an explanation of why including and distributing files like config, css, etc. in a (private or public) nuget package is somehow bad for us to do? This enforcement of segregation seems to only remove value from NuGet, and at the additional cost of causing commotion and upset for users. If someone could explain the value of doing (without any of purist/idealism, or fear-mongering) it may help us to at least not be so combative. |
As described in a recent NuGet team blog post "NuGet now fully integrated into MSBuild", after enabling PackageReference support for projects such as WPF, Windows Forms, or ASP.NET, some packages may not install or work correctly.
The relevant part of the blog post is referenced below:
The NuGet team is current considering the following steps, and will keep this issue updated with progress:
We are working with various project systems to ensure that they have the necessary capabilities to light up PackageReference support.
We are currently analyzing packages hosted on NuGet.org (and elsewhere) to better understand the usage patterns of the functionality listed above (such as Install.ps1, XDT Transforms, etc.) so we can ensure a smooth transition to PackageReference usage in projects. We are going to consider this from the perspective of both package authors and consumers.
The text was updated successfully, but these errors were encountered: