NuGet/Home

"Assembly outside lib folder" warning and packages including MSBuild Tasks

Open

#2,834 opened on May 23, 2016

View on GitHub
 (9 comments) (6 reactions) (0 assignees)HTML (1,459 stars) (292 forks)batch import
Functionality:PackPriority:3Type:Bughelp wanted

Description

Since NuGet 2.5 we can leverage the automatic import of msbuild targets and props files feature and add files such as {packageid}.targets and {packageid}.props to a special \build folder which are automatically added to the project file in which the nuget package is being installed, which is great.

However, when the .targets file uses custom MSBuild tasks that are shipped with the NuGet package, and we add these MSBuild tasks assemblies in the same \build folder, we get the following warning:

Issue: Assembly outside lib folder. Description: The assembly 'build\MyCustomMSBuildTasks.dll' is not inside the 'lib' folder and hence it won't be added as reference when the package is installed into a project. Solution: Move it into the 'lib' folder if it should be referenced.

Based on the the warning message, this seems like a bug. Given the assembly should not be referenced, it does not belong in the \lib folder and (I think) the \build folder would be the right place for it, together with the .targets file that uses it. The \tools folder would be another option, but we get the same warning, so same issue.

Would you agree this is a bug? If yes, than maybe the \build folder should be excluded in the MisplacedAssemblyRule check. Happy to send a PR to fix this.

If this is not a bug, then what would be the recommendation?

The only workaround at the moment (that I know of) is to have the custom MSBuild Tasks assembly in the lib folder, and then use the <references> metadata in the nuspec to be explicit about the assemblies to be referenced and prevent the custom MSBuild Tasks assembly to be referenced in the project.

Contributor guide