Unmanaged Exports(针对.NET的DllExport)和MSBuild错误

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.
1个回答

5

我刚遇到了同样的问题。RGiesecke.DllExport.targets文件引用了$(DevEnvDir),而在运行msbuild的环境中,这个变量不会被定义(但在Visual Studio内部会定义)。我采取了一个快速而简单的方法,即在构建服务器上添加一个系统范围的环境变量(设置为“C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\”),以解决这个问题,因为我很匆忙。


你能更好地解释一下你是如何解决这个问题的吗? - Emir Lima
1
我可以尝试,但我不确定哪个部分不清楚。我添加了一个名为“DevEnvDir”的Windows系统变量,其值为“C:\ Program Files(x86)\ Microsoft Visual Studio 11.0 \ Common7 \ IDE \”。Windows系统变量可以通过控制面板->系统->高级系统设置->高级->环境变量进行设置。 - Matt Burnell

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接