Home: NuGet.exe pack includes assets that come from props/targets from other packages

Created on 3 Nov 2017  路  25Comments  路  Source: NuGet/Home

when i try make a nuget package i use nuget.exe
image
my project has 3 reference
image
when i run nuget pack *.csproj
image
the result is log4net.kafka.3.0.0.nupkg and the .nupkg file is not the structure that i expected
image
that content folder should not be there . the stracture should be like this other nupkg file
image

how could i do to fix this
Look forward to your favourable reply

Customer Sprint Quality Week Pack Backlog 2 NuGet.exe dotnet.exe Bug

Most helpful comment

Why would I do that? If I want everything in the packages.config to be the basis for my NuGet package why would I create a nuspec with exact same thing rather than just running nuget pack from the solution or csproj which is supposed to pull those dependencies and files and references and authors and owners and projectUrl and iconUrl and licenseUrl and description and tags etc into the package?

All 25 comments

here is nuget information

PS C:\Users\muyue\Documents\GitHub\log4net-kafka\src\log4net.kafka> nuget pack .\log4net.kafka.csproj
Attempting to build package from 'log4net.kafka.csproj'.
MSBuild auto-detection: using msbuild version '15.4.8.50001' from 'D:\soft\vs2017\MSBuild\15.0\bin'.
Packing files from 'C:\Users\muyue\Documents\GitHub\log4net-kafka\src\log4net.kafka\bin\Debug'.
Found packages.config. Using packages listed as dependencies
WARNING: Description was not specified. Using 'Description'.
WARNING: Author was not specified. Using 'muyue'.
Successfully created package 'C:\Users\muyue\Documents\GitHub\log4net-kafka\src\log4net.kafka\log4net.kafka.3.0.0.nupkg'.
WARNING: Issue found with package 'log4net.kafka'.

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

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

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

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

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

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

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

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

@youngerier would you share your .csproj file? This looks unexpected.

here is my .csproj file @emgarten

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="..\..\packages\librdkafka.redist.0.11.1\build\net\librdkafka.redist.props" Condition="Exists('..\..\packages\librdkafka.redist.0.11.1\build\net\librdkafka.redist.props')" />
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{2556CD9A-CCC2-4043-9381-AE7CA6050ECF}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>log4net</RootNamespace>
    <AssemblyName>log4net.kafka</AssemblyName>
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Confluent.Kafka, Version=0.11.2.0, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>..\..\packages\Confluent.Kafka.0.11.2\lib\net45\Confluent.Kafka.dll</HintPath>
    </Reference>
    <Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
      <HintPath>..\..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
    </Reference>
    <Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
      <HintPath>..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Core" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Appender\KafkaAppender.cs" />
    <Compile Include="Appender\KafkaSettings.cs" />
    <Compile Include="Extensions\DataTimeExtensions.cs" />
    <Compile Include="Layout\LogstashLayout.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="packages.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\..\packages\librdkafka.redist.0.11.1\build\net\librdkafka.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\librdkafka.redist.0.11.1\build\net\librdkafka.redist.props'))" />
  </Target>
</Project>

i have used .nuspec file to pack

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <id>log4net.kafka</id>
    <version>3.0.0</version>
    <title>log4net.kafka</title>
    <authors>muyue</authors>
    <owners>muyue</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Description</description>
    <copyright>Copyright 漏  2017</copyright>
    <dependencies>
      <dependency id="Confluent.Kafka" version="0.11.2" />
      <dependency id="log4net" version="2.0.8" />
      <dependency id="Newtonsoft.Json" version="10.0.3" />
      <dependency id="librdkafka.redist" version="0.11.1" exclude="Build,Analyzers" /> # Add this line
    </dependencies>
  </metadata>
</package>

but its not work either

@youngerier add a <files> section to define which files are copied and where.

I have tried ues this .nuspec file @emgarten

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <id>log4net.kafka</id>
    <version>3.1.9.9</version>
    <title>log4net.kafka</title>
    <authors>ziggle</authors>
    <owners>ziggle</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Description</description>
    <copyright>Copyright 漏  2017</copyright>
    <dependencies>
      <dependency id="Confluent.Kafka" version="0.11.2" />
      <dependency id="log4net" version="2.0.8" />
      <dependency id="Newtonsoft.Json" version="10.0.3" />
    </dependencies>
  </metadata>
  <files>
    <file src="bin\Debug\x64\*.*" target="lib\x64" />
    <file src="bin\Debug\x86\*.*" target="lib\x86" />
  </files>
</package>

but the .nupkg structure is still worng
image

but only if i comment .csproj the element the package is right
image

and what is the side effect of this operator

can you do a msbuild on your project (using the version shipped with visual studio 15.4 at least) and pass the /bl and /v:diag flag and attach the .binlog file that is generated?

@youngerier it looks like the content is coming in from the librdkakfa.redist package which contains the librdkakfa.redist.props file.

Could you try uninstalling the package, and then reinstalling and adding developmentDependency=true in the dependency in your packages.config file and trying the scenario again?

@rohit21agrawal
I have tried run msbuild with /bl and /v:diag this process without a warning

 msbuild .\log4net-kafka.sln /bl /v:diag

image
and then I use

Update-Package -reinstall

add developmentDependency=true property
image
the .nupkg is still not the right stracture
image
I want to know if the .nupkg have some hidden danger without the content folder
image

Is anyone tracking this? I am having a similar issue, it's as if it is not reading the packages.config but instead loading packages inside bin\Debug and then complaining because they are not in this mysterious lib folder which I tried to create. I also tried using the NuGet Package Explorer to add them to the lib but they disappear from it after saving. Without a solution, is there some sort of work around so I can at least have a working NuGet package?

if you only want the files from the nuspec to be included, then pass the nuspec file as an argument to the pack command instead of csproj file.

@kmbeard I am not sure what is the exact issue you are facing, can you describe in more detail?

Project
If you clone the project and try to run
nuget pack Aptera.AutomatedSelenium.El.Sullivan
in the Package Manger Console
the error you are presented with is:
`Attempting to build package from 'Aptera.AutomatedSelenium.El.Sullivan.csproj'.
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
Packing files from 'D:\Aptera\Aptera.AutomatedSelenium.El.Sullivan\Aptera.AutomatedSelenium.El.Sullivan\bin\Debug'.
Found packages.config. Using packages listed as dependencies
WARNING: Description was not specified. Using 'Description'.
WARNING: Author was not specified. Using 'kbeard'.
Successfully created package 'D:\Aptera\Aptera.AutomatedSelenium.El.Sullivan\Aptera.AutomatedSelenium.El.Sullivan.1.0.0.nupkg'.
WARNING: Issue found with package 'Aptera.AutomatedSelenium.El.Sullivan'.

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

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

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

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

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

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

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

WARNING: Issue: Assembly outside lib folder.
WARNING: Description: The assembly 'content\bin\Debug\Aptera.AutomatedSelenium.El.Sullivan.dll' is not inside the 'lib' folder and hence it won't be added as reference when the package is installed into a project.
WARNING: Solution: Move it into the 'lib' folder if it should be referenced.

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

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

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

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

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

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

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

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

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

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

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

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

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

@kmbeard those files are coming via a dependency which has a targets/props file and adding them to content item group.
to prevent that, you need to have a nuspec file next to your csproj with an empty files tag that will prevent content from being added.

Why would I do that? If I want everything in the packages.config to be the basis for my NuGet package why would I create a nuspec with exact same thing rather than just running nuget pack from the solution or csproj which is supposed to pull those dependencies and files and references and authors and owners and projectUrl and iconUrl and licenseUrl and description and tags etc into the package?

Also when I do that I still have an error about an invalid assembly reference.
PM> nuget pack Aptera.AutomatedSelenium.El.Sullivan
Attempting to build package from 'Aptera.AutomatedSelenium.El.Sullivan.csproj'.
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
Packing files from 'D:\Aptera\Aptera.AutomatedSelenium.El.Sullivan\Aptera.AutomatedSelenium.El.Sullivan\bin\Debug'.
Using 'Aptera.AutomatedSelenium.El.Sullivan.nuspec' for metadata.
Found packages.config. Using packages listed as dependencies
nuget : Invalid assembly reference 'Newtonsoft.Json.dll'. Ensure that a file named 'Newtonsoft.Json.dll' exists in the lib directory.
At line:1 char:1

  • nuget pack Aptera.AutomatedSelenium.El.Sullivan
  • ~~~~~~~~~~~

    • CategoryInfo : NotSpecified: (Invalid assembl... lib directory.:String) [], RemoteException

    • FullyQualifiedErrorId : NativeCommandError

Only this happens for each dll.

you only need to create a boilerplate nuspec file (which you can do using the nuget.exe spec command), all your dependencies would still be read from packages.config.

What about the files that I want to be included? When I use a boilerplate nuspec it still throws that error I posted above and it happens for each dependency.

Can you do a restore to make sure all dependencies exist in the packages folder?

Completed "nothing to restore"

Same issue here:

C:\dev\proyecto26\rest-client\src\Proyecto26.RestClient>nuget pack Proyecto26.RestClient.nuspec
Attempting to build package from 'Proyecto26.RestClient.nuspec'.
Successfully created package 'C:\dev\proyecto26\rest-client\src\Proyecto26.RestClient\Proyecto26.RestClient.1.2.2.nupkg'.
WARNING: Issue found with package 'Proyecto26.RestClient'.

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

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

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

Let me know what you think guys, thanks in advance!

I had some trouble with this when running dotnet pack on Linux. The files ended up in the right place in the package though. The solution was to use forward-slashes instead of back-slashes.

Not sure if anyone else here is dealing with exactly the same problem as me, but my problem turned out to be caused by Visual Studio. I was able to solve a very similar issue by doing the following:
1) Move my static, referenced DLLs into the magical "lib" folder
2) For those static DLLs, make sure that they are marked as "None" under "Properties -> Build Action".

image

In my case, the DLLs were originally marked as "Content", which would cause the compiler to inject them into a /content folder during compilation.

A newer dup of this issue was reported in https://github.com/NuGet/Home/issues/8867.
I have added a comment for some pointers on the work that'd need to be done to fix this bug.
https://github.com/NuGet/Home/issues/8867#issuecomment-569765203.

@dominoFire
Remember to read: https://github.com/NuGet/Home/issues/8867#issuecomment-569765203

Was this page helpful?
0 / 5 - 0 ratings