4

我已经安装了 Nuget 包“Unmanaged Exports (dllExport for .NET)。使用 MS Visual Studio 2010 可以正常工作。

使用 MSBuild (Windows SDK v7.1) 我得到一个错误Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

知道如何解决这个问题吗?

部分 MSBuild 输出:

MethodDeclarationParserAction: Found method: HSAdapter.HSAdapter..method public hidebysig static void  'CreateHSAdapterInstance'([out] class 'HSAdapter'.'IHSAdapter'&  marshal( interface ) 'instance') cil managed
MethodPropertiesParserAction: Removing RGiesecke.DllExport.DllExportAttribute from HSAdapter.HSAdapter.CreateHSAdapterInstance
DeleteExportAttributeParserAction: Adding .vtentry:0 .export:CreateHSAdapterInstance
Parse IL: Deleting unused reference to RGiesecke.DllExport.Metadata.
Parse IL: Parsing 1676 lines of IL took 51 ms.
D:\HS4\packages\UnmanagedExports.1.2.4.23262\tools\RGiesecke.DllExport.targets(42,5): error : Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
at System.String.Format(IFormatProvider provider, String format, Object[] args)
at RGiesecke.DllExport.DllExportNotifier.Notify(Int32 severity, String code, String fileName, Nullable`1 startPosition, Nullable`1 endPosition, String message, Object[] values) in d:\Work\Libraries\RGiesecke.DllExport\RGiesecke.DllExport\DllExportNotifier.cs:line 135
at RGiesecke.DllExport.DllExportNotifier.Notify(Int32 severity, String code, String message, Object[] values) in d:\Work\Libraries\RGiesecke.DllExport\RGiesecke.DllExport\DllExportNotifier.cs:line 119
at RGiesecke.DllExport.Parsing.DllExportNotifierWrapper.Notify(Int32 severity, String code, String message, Object[] values) in d:\Work\Libraries\RGiesecke.DllExport\RGiesecke.DllExport\Parsing\DllExportNotifierWrapper.cs:line 41
at RGiesecke.DllExport.Parsing.IlAsm.RunLibTool(CpuPlatform cpu, String fileName, String directory) in d:\Work\Libraries\RGiesecke.DllExport\RGiesecke.DllExport\Parsing\ILAsm.cs:line 212
at RGiesecke.DllExport.Parsing.IlAsm.RunCore(CpuPlatform cpu, String fileName, String ressourceParam, String ilSuffix) in d:\Work\Libraries\RGiesecke.DllExport\RGiesecke.DllExport\Parsing\ILAsm.cs:line 186
at RGiesecke.DllExport.Parsing.IlAsm.Run(String outputFile, String ilSuffix, CpuPlatform cpu) in d:\Work\Libraries\RGiesecke.DllExport\RGiesecke.DllExport\Parsing\ILAsm.cs:line 123
at RGiesecke.DllExport.Parsing.IlAsm.ReassembleFile(String outputFile, String ilSuffix, CpuPlatform cpu) in d:\Work\Libraries\RGiesecke.DllExport\RGiesecke.DllExport\Parsing\ILAsm.cs:line 75
at RGiesecke.DllExport.DllExportWeaver.RunIlAsm(IlAsm ilAsm) in d:\Work\Libraries\RGiesecke.DllExport\RGiesecke.DllExport\DllExportWeaver.cs:line 151
at RGiesecke.DllExport.DllExportWeaver.Run() in d:\Work\Libraries\RGiesecke.DllExport\RGiesecke.DllExport\DllExportWeaver.cs:line 81
at RGiesecke.DllExport.MSBuild.ExportTaskImplementation`1.Execute() in d:\Work\Libraries\RGiesecke.DllExport\RGiesecke.DllExport.MSBuild\ExportTaskImplementation.cs:line 243
Done Building Project "D:\HS4\HSAdapter\HSAdapter.csproj" (default targets) -- FAILED.
4

1 回答 1

5

我刚刚遇到了同样的问题。RGiesecke.DllExport.targets 文件引用 $(DevEnvDir),它不会在您运行 msbuild 的环境中定义(但会在 Visual Studio 中)。我采用快速而肮脏的方法在构建服务器上添加系统范围的环境变量(设置为“C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\”)来解决它,因为我很着急。

于 2013-07-31T06:13:46.670 回答