NuGet does not pack all files into the output directory. What am I missing?

I am trying to create a NuGet package from .csproj. I successfully compiled the project, and the output folder contains all the necessary files (my assembly and all its dependencies). However, NuGet seems to put the assembly created by .csproj in the package, and not any of its dependencies. My command line looks like this:

nuget pack MyProject.csproj -Property Configuration=Release 

and my .nupkg file has my assembly in the lib folder. I successfully got NuGet to work in other projects, but it so happened that this project refers to the Enterprise Library logging unit, but was not received through NuGet. I am not sure if this could be due to my problem or not.

Any thoughts on why he is not picking up dependencies?

+4
source share
1 answer

If you need to constantly update your nuspec file, it is really just an XML file (as I am sure you know), so there are some very good tools you can use from MSBuild to automate nuspec / update creation. From the command line, MSBuild provides several tasks that can update or transform XML, and I used the MSBuild community tasks to configure the original nuspec. For example, by default, nuspec contains several rows with a broiler table that I do not need, so I use XmlUpdate tasks to delete them.

Although I have not looked at the csproj file for links without links, I think this is possible with a little research. Here are some links to blog posts that describe my experience with NuGet automation, which can help you get started:

Creating packages with NuGet using MSBuild - This article contains some basic NuSpec updates, because the described package is no different from the type of package NuGet already knows how to automate.

Managing MEF Parts with Nuget - This article includes some more complex updates to support the distribution of MEF parts as run-only links.

If you plan to do this a lot, don’t want to mess with MSBuild, or just want to return the behavior you liked from the version of ProjectFactory.cs until 1360, NuGet supports third-party extension through MEF. You can go into the original control and get the earlier code that you like and create a custom command (like custompack ) that provides this behavior. Then you can use it from the command line as follows:

nuget custompack MyProject.csproj -Property Configuration=Release

I think this is a really cool aspect of NuGet, but I haven't played with it myself yet. Here is an article explaining how to do this:

Extend NuGet Command Prompt

So, although David mentioned that NuGet is not intended to support this scenario, if the scenario is right for you, you can go this route to expand NuGet to suit your needs.

+4
source

Source: https://habr.com/ru/post/1400514/


All Articles