System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
Ticket Hash: b2c278db3884e37ebda76aeac4ebe8dd45884f8e
Title: Interop files missing during Post-build event (SDK style csproj)
Status: Closed Type: Packaging
Severity: Minor Priority: Medium
Subsystem: NuGetPackage Resolution: Fixed
Last Modified: 2020-05-25 19:51:47
Version Found In: 1.0.112.1
User Comments:
anonymous added on 2019-08-14 12:54:55:
The interop files SQLite.Interop.dll in the x86/x64 subfolders not present during Visual Studio's post-build event in VS 2019. They are placed there (by the build target in System.Data.SQLite.Core.targets?) after the post-build event is finished.

A similar problem was reported and resolved in ticket http://system.data.sqlite.org/index.html/info/f16c93a932

The file System.Data.SQLite.Core.targets contains a list of Visual Studio versions (line 131 ff) where VS 2019 ("16.0") is missing, but I don't know whether this is related.

Build environment
-----------------

* Win 10 German
* Visual Studio 2019 (16.2.2)
* .Net 4.7.2

Example to reproduce
--------------------

SQLitePostBuild.csproj (contains post-build event that checks for the interop file in debug subfolder, build forced to fail if not found):
###
  <Project Sdk="Microsoft.NET.Sdk">
  
    <PropertyGroup>
      <OutputType>Exe</OutputType>
      <TargetFramework>net472</TargetFramework>
    </PropertyGroup>
  
    <ItemGroup>
      <PackageReference Include="System.Data.SQLite" Version="1.0.111" />
    </ItemGroup>
  
    <Target Name="PostBuild" AfterTargets="PostBuildEvent">
      <Exec Command="REM Checks whether the interop file exists during Post-build event.&#xD;&#xA;REM Other files in the output folder (ex. SQLitePostBuild.exe) would be found.&#xD;&#xA;IF EXIST &quot;bin\Debug\net472\x86\SQLite.Interop.dll&quot; (&#xD;&#xA;  exit 0&#xD;&#xA;) ELSE (&#xD;&#xA;  exit 1&#xD;&#xA;)" />
    </Target>
  
  </Project>
###

Program.cs (just a minimal hello world):

###
  namespace SQLitePostBuild
  {
    class Program
    {
      static void Main() => System.Console.WriteLine("Hello SQLite!");
    }
  }
###

anonymous added on 2019-08-14 14:51:47:
I could reproduce this with Visual Studio 2017 (15.9.15) as well. => Not related to the VS version.

It looks like it is a problem with the new "SDK" style *.csproj file format.

See attachment "OldProjectFormat.zip" for an example using the old file format that works as expected.

Only change I had to make in the post-build event is that the new "SDK" style has the project directory as start for relative paths while the old style starts directly from the bin\debug folder. Perhaps the issue is related?

anonymous added on 2019-08-14 15:48:42:
The issue is not related to PackageReference vs packages.conf. With old-style project files, both ways to reference NuGet packages work.

By default only .Net Standard and .Net Core projects use this file format. Since System.Data.SQLite.Core 1.0.110 the build folder in the NuGet package no longer contains a targets file for netstandard2.0 (it did exist in 1.0.109).

It looks like this is more of an edge case that might not be officially supported. I have therefore reduced the severity to "Minor".

Workaround for me is to use the old project file format.

mistachkin added on 2019-08-15 23:31:14:
I think your assessment is correct.  The NuGet build targets file is designed to
support the legacy ".csproj" project file format.

For .NET Standard / .NET Core projects, I believe the interop files should be
copied (by NuGet?) from the appropriate "runtimes\*\native\netstandard2.0"
directories.

anonymous added on 2020-04-07 06:11:05:

I can confirm this is still an issue and was resolved by adding the '$(VisualStudioVersion)' == '16.0' line into the System.Data.SQLite.Core.targets file


mistachkin added on 2020-04-07 15:06:39:

Thanks for the update. Fixed on trunk via check-in [a6a4385c2c5b845e].

I'm planning on creating a new NuGet package version shortly, e.g. 1.0.112.2.