Visual studio 2013 NUget:无法从obj提取元数据

Visual studio 2013 NUget:无法从obj提取元数据,visual-studio-2013,msbuild,nuget,Visual Studio 2013,Msbuild,Nuget,使用nuget 2.8.3从Visual Studio 2013 Update 4构建nuget软件包时,我收到以下警告: EXEC : warning : Unable to extract metadata from 'MyAssembly.dll'. [D:\Development\MyAssembly\MyAssembly.csproj] EXEC : warning : Description was not specified. Using 'Description'. [D:\De

使用nuget 2.8.3从Visual Studio 2013 Update 4构建nuget软件包时,我收到以下警告:

EXEC : warning : Unable to extract metadata from 'MyAssembly.dll'. [D:\Development\MyAssembly\MyAssembly.csproj]
EXEC : warning : Description was not specified. Using 'Description'. [D:\Development\MyAssembly\MyAssembly.csproj]
EXEC : warning : Author was not specified. Using 'GDo'. [D:\Development\MyAssembly\MyAssembly.csproj]
EXEC : warning : Unable to extract metadata from 'MyAssembly.dll'. [D:\Development\MyAssembly\MyAssembly.csproj]
EXEC : warning : Description was not specified. Using 'Description'. [D:\Development\MyAssembly\MyAssembly.csproj]
EXEC : warning : Author was not specified. Using 'GDo'. [D:\Development\MyAssembly\MyAssembly.csproj]
生成的nuget包名为MyAssembly。1.0.0.nupkg,而我期望的是1.4.4

尽管有以下AssemblyInfo.cs

using System.Reflection;

// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MyAssembly")]
[assembly: AssemblyDescription("components and factory")]
[assembly: AssemblyVersion("1.0.0.0")] // change this when the interface changes
[assembly: AssemblyInformationalVersion("1.4.4")] // used by the NuGet pack implementation
我正在使用以下生成后事件:

"$(DEVTOOLS)\NuGet\NuGet.exe" pack "$(ProjectPath)" -symbols -IncludeReferencedProjects -Properties "Configuration=$(Configuration);Platform=$(Platform);OutputPath=Obj\$(Configuration)" -NonInteractive -MinClientVersion 2.5
我们在所有项目上使用此生成后事件,它们都会在Visual Studio和TFS CI生成服务器上生成正确的包

当我从该特定项目的命令行运行msbuild时,可以看到nuget命令被调用为:

"D:\DevTools\NuGet\NuGet.exe" pack "D:\Development\MyAssembly\MyAssembly.csproj" -symbols -IncludeReferencedProjects -Properties "Configuration=Debug;Platform=AnyCPU;OutputPath=Obj\Debug" -NonInteractive -MinClientVersion 2.5
Attempting to build package from 'MyAssembly\MyAssembly.csproj'.
Packing files from 'D:\Development\MyAssembly\Obj\Debug'.
EXEC : warning : Unable to extract metadata from 'MyAssembly.dll' [D:\Development\MyAssembly\MyAssembly.csproj]
File from dependency is not changed. File 'native.dll' is not added.
Found packages.config. Using packages listed as dependencies
EXEC : warning : Description was not specified. Using 'Description'. [D:\Development\MyAssembly\MyAssembly.csproj]
EXEC : warning : Author was not specified. Using 'GDo'. [D:\Development\MyAssembly\MyAssembly.csproj]
Successfully created package 'D:\Development\MyAssembly\bin\Debug\MyAssembly.1.0.0.0.nupkg'.
当我更改此命令以引用bin文件夹而不是obj文件夹时:

"D:\DevTools\NuGet\NuGet.exe" pack "D:\Development\MyAssembly\MyAssembly.csproj" -symbols -IncludeReferencedProjects -Properties "Configuration=Debug;Platform=AnyCPU;OutputPath=**bin**\Debug" -NonInteractive -MinClientVersion 2.5
我获得了预期的行为,软件包按照预期构建,版本正确,等等:

Attempting to build package from 'MyAssembly.csproj'.
Packing files from 'D:\Development\MyAssembly\bin\Debug'.
File from dependency is not changed. File 'native.dll' is not added.
Found packages.config. Using packages listed as dependencies
Successfully created package 'D:\Development\MyAssembly\MyAssembly.1.4.4.nupkg'.
但这很奇怪。例如,生成后事件适用于所有其他项目

  "D:\DevTools\NuGet\NuGet.exe" pack "D:\Development\MyOtherAssembly\MyOtherAssembly.csproj" -symbols -IncludeReferencedP
  rojects -Properties "Configuration=Debug;Platform=AnyCPU;OutputPath=Obj\Debug" -NonInteractive -MinClientVersion 2.5
  Attempting to build package from 'MyOtherAssembly.csproj'.
  Packing files from 'D:\Development\MyOtherAssembly\Obj\Debug'.
  Found packages.config. Using packages listed as dependencies
  Successfully created package 'D:\Development\MyOtherAssembly\bin\Debug\MyOtherAssembly.1.4.1.nupkg'.
更奇怪的是,在另一个具有相同源代码的开发人员的机器上,这个坏项目的构建工作得很好。Manally runnig msbuild确实会产生相同的错误,但生成的包具有正确的版本。(是的,我尝试从TFS获取新的源代码树,但没有成功) 有人能解释一下原因吗


更新:签入后,我们的TFS服务器现在有相同的生成问题,只生成nuget软件包版本1.0.0.0。

nuget隐藏了打包失败的原因。当我们使用开关手动构建包时,-Verbosity detailed 我们从nuget收到一个完整的stacktrace,在我们的例子log4net中,在一个依赖dll上有一个FileNotFoundException。事实上,这个dll并没有复制到obj文件夹中

在我们的一个类中,我们将其缩小为以下属性:

[assembly: log4net.Config.XmlConfigurator(Watch = true)]

这导致nuget在开始读取程序集元数据时立即查找log4net.dll。我们通过将log4net dll复制到obj文件夹来验证这一点。(生成成功)然后我们删除了此属性,从而完全解决了问题。

我注意到了这种行为,因为nuget没有从我的程序集中获取版本号。上面的消息仅由nuget 2.8.6显示,但我使用的是3.5和/或4.0,它不报告警告,但也无法提取元数据

对我来说,这个问题是由我拥有多个版本的nuget并重命名可执行文件以匹配该版本引起的。我将2.8.6版本重命名为
nuget.2.8.6.exe
,将3.5版本重命名为
nuget.3.5.0.exe
,将4.0版本重命名为
nuget.4.0.0.exe
。3.5的
fuslogvw
输出显示它找不到文件
nuget3.5.0.exe.config
,这似乎是导致问题的原因


当我将可执行文件重新命名为
nuget.exe
时,一切都重新开始工作。

您是否尝试过进行干净的构建?您可能有以前版本中的一些积垢导致了问题。是的,我尝试过清理、构建、重建、发布、调试等各种配置,但都没有效果。我刚刚遇到过同样的问题,但在创建Xamarin.iOS NuGet包时,我尝试了上面的测试,手动复制了Xamarin.iOS DLL,然而,我的解决方案是将特定程序集标记为Copy Local=True