【发布时间】:2015-01-08 12:26:13
【问题描述】:
在使用 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
我们在所有项目上都使用此构建后事件,它们都会在 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'.
更奇怪的是,损坏的项目的构建在具有相同源代码的另一个开发人员的机器上运行良好。手动运行 msbuild 确实会产生相同的错误,但生成的包具有正确的版本。 (是的,我尝试从 TFS 获取新的源代码树,但无济于事) 有人能解释一下可能是什么原因吗?
更新:签入后,我们的 TFS 服务器现在有相同的构建问题,并且仅生成 nuget 包版本 1.0.0.0。
【问题讨论】:
-
您尝试过干净构建吗?您可能在以前的构建中遇到了一些问题,导致问题。
-
是的,我做到了,试过clean,build,rebuild,release,debug,各种配置,都无济于事。
标签: visual-studio-2013 msbuild nuget