You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When publishing an app from Mac targeting Windows, required native files are not included. The same app built from Mac using dotnet build works fine on both platforms.
I'm not sure if this is me misunderstanding dotnet publish, a problem with my configuration, or a potential problem with the CLI. Appreciate any help you can provide. :)
usingSystem;usingSystem.IO;usingCouchbase.Lite;namespaceCblCount{classProgram{privateconststringCblite2Suffix=".cblite2";staticvoidMain(string[]args){if(args.Length!=1){Console.WriteLine("Usage: CblCount (path_to_cblite2_db)");return;}vardbPath=args[0];if(!Directory.Exists(dbPath)){Console.WriteLine($"{dbPath} does not exist");return;}elseif(!dbPath.EndsWith(Cblite2Suffix)){Console.WriteLine($"{dbPath} must end with {Cblite2Suffix}");return;}// CBL .NET expects path without .cblite2 suffix and without trailing path separatorvarpathWithoutSuffix=dbPath.Substring(0,dbPath.Length-Cblite2Suffix.Length);vardb=newDatabase(pathWithoutSuffix);varcount=db.Count;varcountString=count==1?"1 document":$"{count} documents";Console.WriteLine($"{dbPath} contains {countString}.");}}}
Create a fake Couchbase database:
$ mkdir db.cblite2
Can then run on any platform using:
~/dev/git/CblCount % dotnet run db.cblite2
db.cblite2 contains 0 documents.
The output directory includes native Couchbase components:
Copying publish/win to Desktop\win on Windows and then running gives the following error (with paths elided):
$ ./CblCount.exe test.cblite2
Unhandled exception. System.TypeInitializationException: The type initializer for 'Couchbase.Lite.Database' threw an exception.
---> System.TypeInitializationException: The type initializer for 'LiteCore.Interop.Native' threw an exception.
---> System.DllNotFoundException: Could not find LiteCore.dll! Nothing is going to work!
Tried searching in:
...\runtimes\win7-x64\native\LiteCore.dll
...\Desktop\win\x64\LiteCore.dll
...\Desktop\win\bin\x64\LiteCore.dll
at Couchbase.Lite.Support.NetDesktop.LoadLiteCore()
at LiteCore.Interop.Native..cctor()
--- End of inner exception stack trace ---
at LiteCore.Interop.Native.c4log_getDomain(Byte* name, Boolean create)
at Couchbase.Lite.Logging.FileLogger.SetupDomainObjects()
at Couchbase.Lite.Logging.FileLogger..ctor()
at Couchbase.Lite.Logging.Log..ctor()
at Couchbase.Lite.Database..cctor()
--- End of inner exception stack trace ---
at Couchbase.Lite.Database..ctor(String name, DatabaseConfiguration configuration)
at CblCount.Program.Main(String[] args) in .../CblCount/Program.cs:line 29
Inspecting the published output shows that x64/LiteCore.dll and x86/LiteCore.dll are missing (these are in build output under bin/Debug/netcoreapp3.0/runtimes/win7-*/native, just not in published output).
If I run the dotnet publish -r win-x64 command from the Windows machine, the application works as expected:
$ dotnet publish -r win-x64 -o pub/win --self-contained true
Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 55.13 ms for ...\Desktop\CblCount\CblCount.csproj.
CblCount -> ...\Desktop\CblCount\bin\Debug\netcoreapp3.0\win-x64\CblCount.dll
CblCount -> ...\Desktop\CblCount\pub\win\
$ ./pub/win/CblCount.exe db.cblite2
db.cblite2 contains 0 documents.
The app built on Windows targeting osx-x64 also works correctly once the appropriate chmod u+x permission update has been applied.
Expected results
I expected that publishing on any platform and targeting using -r would include the required native files for that platform. In my actual use case I am building on Linux using Docker and trying to get Mac and Windows apps from that CI build.
Other things tried
I have tried different RIDs (both in publish command and in .csproj), different settings for --self-contained, and also adding <IncludeSymbolsInSingleFile>true</IncludeSymbolsInSingleFile> to csproj as I saw suggested in another issue. I also get the same results using /p:PublishSingleFile=true (which is what I'm ultimately aiming to get for the Windows app).
I have not tried updating csproj to manually copy over these files based on targeted RID yet, or specifying different publish options.
When publishing an app from Mac targeting Windows, required native files are not included. The same app built from Mac using
dotnet build
works fine on both platforms.I'm not sure if this is me misunderstanding
dotnet publish
, a problem with my configuration, or a potential problem with the CLI. Appreciate any help you can provide. :)Steps to reproduce
Create
CblCount.csproj
:Create
Program.cs
:Create a fake Couchbase database:
Can then run on any platform using:
The output directory includes native Couchbase components:
Now publish:
Observed results
The Mac app works as expected:
Copying
publish/win
toDesktop\win
on Windows and then running gives the following error (with paths elided):Inspecting the published output shows that
x64/LiteCore.dll
andx86/LiteCore.dll
are missing (these are in build output underbin/Debug/netcoreapp3.0/runtimes/win7-*/native
, just not in published output).If I run the
dotnet publish -r win-x64
command from the Windows machine, the application works as expected:The app built on Windows targeting
osx-x64
also works correctly once the appropriatechmod u+x
permission update has been applied.Expected results
I expected that publishing on any platform and targeting using
-r
would include the required native files for that platform. In my actual use case I am building on Linux using Docker and trying to get Mac and Windows apps from that CI build.Other things tried
I have tried different RIDs (both in
publish
command and in.csproj
), different settings for--self-contained
, and also adding<IncludeSymbolsInSingleFile>true</IncludeSymbolsInSingleFile>
tocsproj
as I saw suggested in another issue. I also get the same results using/p:PublishSingleFile=true
(which is what I'm ultimately aiming to get for the Windows app).I have not tried updating
csproj
to manually copy over these files based on targeted RID yet, or specifying different publish options.Possibly related
Details
Mac info
Windows info
The text was updated successfully, but these errors were encountered: