使用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.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
我们在所有项目上使用此post-build事件,并且它们都在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'.
但这很奇怪。 post build事件适用于所有其他项目,例如
"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。
答案 0 :(得分:4)
包装失败的原因被nuget隐藏了。当我们使用开关 -Verbosity detailed 手动构建包时 我们从nuget收到了一个完整的堆栈跟踪,在依赖的dll上有一个FileNotFoundException,在我们的例子中是log4net。事实上,这个DLL不会被复制到obj文件夹。
我们将其缩小为我们其中一个类中的以下属性:
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
这导致nuget在开始阅读程序集元数据时查找log4net.dll。我们通过将log4net dll复制到obj文件夹来验证这一点。 (构建成功)然后我们删除了这个属性,这完全解决了这个问题。
答案 1 :(得分:0)
我注意到了这种行为,因为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
后,所有内容都重新开始工作。