MsBuild copies wrong dll (x86 to x64) to build folder
Hi. focusing problem with usage of native library.
What im trying to achive: x-platform library (nuget) that uses native dlls specified by target platform.
12 Replies
What i have is:
primary csproj. gpt says that it should work while it doesn't.
When im using
Sample
x86 all works fine. But if i switch to x64 i see x86 dll in x64 folder.
And that's how Sample
project looks like
i can't understand how to properly configure MsBuild to copy correct Dll depending on target platform.
im also sure that lib/[plat]/lua54.dll has correct versions of dlls
------------
What i want:
LuaDLL - primary project with bindings to a lua
Sample - PackageReference to LuaDLL to test apis (and then convert to xUnit project)
LuaDLL.nuget - as crossplatform nuget. so it whould be enough just to import
and useEnable MSBuild bin log and see what confused the engine to use the wrong dll, https://msbuildlog.com/ Then depending on your findings, you either fix that issue in your script, or report a bug to Microsoft https://github.com/dotnet/msbuild/issues
For Core you place them in the runtimes folder.
For Framework you need to write a targets file to copy them.
For in tree consumption you have to do it in custom targets as well.
using net9
should i share logs with you?
Please learn to analyze the logs yourself. It's not very difficult. If you do need technical support to assist, you can open a support case via https://support.microsoft.com
Microsoft Support
Microsoft Support is here to help you with Microsoft products. Find how-to articles, videos, and training for Microsoft Copilot, Microsoft 365, Windows, Surface, and more.
seems like it just ignores RID in NativeLibrary definition when this project used with package reference
it found 2 candidates (and because thay both is lua54.dll) it copies one over another
ok. seems like this hack helped and it works more or less properly
in Sample.csproj
thanks @Lex Li for pointing into logs
lets summarize.
LuaDll.csproj still uses
NativeLibrary
.
aka
And Sample.csproj
is just
I don't know what NativeLibrary is.
Unknown User•7d ago
Message Not Public
Sign In & Join Server To View
Mostly the platforms property isn't very useful.
Unknown User•7d ago
Message Not Public
Sign In & Join Server To View
RuntimeIdentifier is really the replacement.
It is, because it does drive out a bunch of things. But it's also set by RID.
It is not necessary to use Platforms at all.
Unknown User•7d ago
Message Not Public
Sign In & Join Server To View