Unmanaged exports (DllExport for .NET) and MSBuild error

I installed the Nuget package "Unmanaged Exports (dllExport for .NET). This works fine using MS Visual Studio 2010.

Using MSBuild (Windows SDK v7.1) I get an error message Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

Any idea how this can be resolved?

Partial MSBuild output:

 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
source share
1 answer

I ran into the same problem. The RGiesecke.DllExport.targets file refers to $ (DevEnvDir), which will not be defined in the environment in which you are running msbuild (but will be from Visual Studio). I took a quick and dirty approach to add a system-wide environment variable on the build server (set to "C: \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ Common7 \ IDE \") to get around it as I was in a hurry.

+5
source

Source: https://habr.com/ru/post/1486785/


All Articles