NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

Copying content files into the specific folder. #10199

Open TaiNguyen2406 opened 4 years ago

TaiNguyen2406 commented 4 years ago

The problem is I need a way to copy content files into the specific folder of the project that is installing my NuGet package.

I can get a reference to it to show up in Visual Studio image But what I need is real files, not a referral link. something like this image

rrelyea commented 4 years ago

Believe this is a duplicate of: https://github.com/NuGet/Home/issues/8779

TaiNguyen2406 commented 4 years ago

Believe this is a duplicate of: #8779

No, I don't think it is similar to #8779

It is more similar to #6743 and I used this workaround using MSBuild and it worked but I wonder why doesn't Nuget support or any official document for this case?

zkat commented 4 years ago

@TaiNguyen2406 can you expand a bit more on the scenario you're trying to solve here? Why do you need to copy, specifically? As much detail as you can share is more than welcome.

TaiNguyen2406 commented 4 years ago

My package contains some js and CSS files and when installed, I want to copy these files to the modules/_proteced folder. I created a routing to these files so I need it in here physically not a reference link

KallDrexx commented 3 years ago

@TaiNguyen2406 can you expand a bit more on the scenario you're trying to solve here? Why do you need to copy, specifically? As much detail as you can share is more than welcome.

Just to piggy back on this, here is a non-web scenario where I need this functionality.

I have a C# particle engine, and a nuget package with integrations into a specific 2d game engine. Part of this integration is a plugin for a tool that game developers using the engine has. This tool makes it easy to add particle effects created with the particle system and hook it up to your game objects.

So anyone who wants to use the particle system with their game needs 2 things setup: 1) Add the Parme.Frb nuget package so their code links against the library 2 )Add the plugin for the tool into the tool's plugin directory.

When the editor opens a C# game project, it will look for project specific plugins in the csproj-directory/Plugins/ folder. Previously I simplified this by users by having the Parme.Frb copy the plugin files into the project's Plugins/ directory. This is a directory at the project root and is not relevant to the bin/ output of their game (the game doesn't need the plugins, only the developers utilizing the game engine's editors do).

However, after the engine upgraded their starter projects from packages.json to PackageReference we notice this stopped working.

There are other plugin systems for this game editor that will need the same functionality. The devs of that engine were hoping they could utilize Nuget for deploying and allowing projects to manage versions of these plugins, but it seems like this functionality was taken away.

I will try the msbuild trick to see if that gets me over the current hurdle, but just wanted to note an additional use case for this.

tbolon commented 3 years ago

Bump for this issue.

The story about contentFiles and asp.net core project is in an unidentified state.

long/short story: I was trying to use the bootstrap nuget package which is still listed as an official way to install it on a fresh .net 5 web app, and discovered that the contentFiles are linked and not copied on the project directory. See also this stackoverflow question

So the only way to make it work was to add manual msbuild steps, as describe in #6743.

There should be clarifications about contentFiles items and web projects:

Either you could :

Perhaps I missed some official documentation about the discrepancy of nuget as content files provider for web resources, and if it's the case maybe we should recommend bootstrap to simple mark the nuget package as obsolete and instruct users to use libman for .net development?

supergibbs commented 3 years ago

At least for Bootstrap, the nuget package started with .NET Framework but now nuget isn't recommended for frontend assets. With Visual Studio, libman is built in. Otherwise using npm or something external is pretty easy with CI tools. In any case, I'll work with the Bootstrap team to update the docs to clarify it's supported for .NET Framework projects, not .NET Core/v5.

tbolon commented 3 years ago

Thank you for this clarification. If you change the documentation to explain that the nuget package is not aimed at .NET v5+ users, I suggest, as you said, to point readers to the libman overview page.

supergibbs commented 3 years ago

Here is the PR if you want to review: https://github.com/twbs/bootstrap/pull/35124