-
Notifications
You must be signed in to change notification settings - Fork 257
How to include file in the root of a project? #5910
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
@pavele by the root of the project, you mean the root of the nupkg? |
There are multiple ways you can achieve this. First of all though, we'd strongly discourage shipping things like a linter through a package. I would suggest you do this by including a target file that would do the copying for you. More info here: |
You may want to consider shipping a template as a NuGet package instead of trying to make a NuGet package add files to a project. $ dotnet new -i MyCompany.Templates.ESLint #downloads the template package from nuget feeds
$ dotnet new mycompany-eslint #drops an .eslintrc file |
Thanks everyone for the prompt replies. @rohit21agrawal I'm looking for approach to put files in the .net core project @nkolev92 I'd be very happy to see if there is a different, better approach instead of dumping linter files. The current state with linters, stylecop, etc in my view is complete mess. StyleCop analyzers use 2 different types of config - rulesets and the stylecop.json. The linter and the editorconfig files should be placed in the root folder - for linters it is because the tools don't "understand" the .csproj model and for .editorconfig it is again similar reason - the editors don't use .csproj a lot. But using msbuilds files that are refenrenced by the nuspec just to copy file in the root of a project sounds like complete overkill to me. In case this is by design then all of the documentation available on MSDN related to content and content files is not explaining it correctly. @dasMulli - this is not a working approach since it will force the projects to be recreated and then again any subsequent updates will recreation of projects. |
I understand the difficulty, but I was referring to item templates, not project templates. so you'd just |
@pavele I understand your confusion about Please go through https://docs.microsoft.com/en-us/nuget/schema/nuspec#including-content-files which gives a little better idea about these techniques. Essentially, |
@pavele other alternative is to write a msbuild target in your nuget package that runs before build that copies over the file to the root of your project. |
@jainaashish Thank you for the information, I've read this posting here and than you for your help, we'll handle this. Btw another are that I consider problematic is the implementation of the target/props. The fact that the changes are "hiddenly" applied on files in the "Obj" folder could again lead to a lot of problems/errors. It is similar problem in my view - some changes or project artifacts will be stored in locations which are not the "standard" like file in the root of the project. |
Cannot find a way to "copy files to the project root" as it's documented in Microsoft's latest nuget docs (1/25/2021):
Tried content and contentFiles (not documented) but nothing copies project into the root. Only way is to run a target that copies the files on compilation, which is too late. If nuget doesn't support this basic feature would you please document it and maybe provide an alternative or an enhancement request? I understand you discourage copying files into a project, but it's a quite common and normal requirement in several real-world cases where files should be copied into a project. |
Details about Problem
NuGet product used: Package Manager Console and VS UI
NuGet version (x.x.x.xxx): 3.+
dotnet.exe --version (if appropriate): 2.0
VS version (if appropriate): 2017, 15.3.4
OS version (i.e. win10 v1607 (14393.321)): Windows 10
I'm unable to create a nuget package that simply adds a file in the root of the project. I've tried everything - nuspec with content, contentFiles, msbuild (csproj) project ContentTargetFolders and PackagePath. I'm simply unable to accomplish such simple task. I'm able to include files as links in a content folder but this is not working for me since the files physically are in the nuget folders in my profile.
Think of the following simple scenario - create a nuget package with an ".eslintrc" file that is physically located in the root of the project.
Thanks,
Pavel
The text was updated successfully, but these errors were encountered: