System.Buffers part 2

Hi,
Ive added a nuget reference to System.Net.Json and it has System.Buffers as a dependency.
Here is the example

SystemTextJson.zip (1.5 MB)

System.Buffers isn’t copied local so the console app wont run.

I recall the problems I had last time with reference assemblies.

I think there is still an issue and somehow it needs to get copied to the bin folder. From reading the thread it doesn’t copy the lib if its .net standard, I dont really know what to suggest.

Cheers,
John

Wasn’t the problem last time that is was copied, and we fixed that? In any case, I’ll have look at the project & refs and see whats going on…

Yes thats what I thought but now Im reconsidering. I think my webapp ran ok without system.buffers. I added a reference to this https://www.nuget.org/packages/Microsoft.Extensions.Logging.AzureAppServices/3.0.0
which references System.Text.Json. While starting up it now complains about a missing System.Buffers.

Will this one be looked into ?

I still have no idea what to do with this. If I “fix this back”, then the thing I fixed for you half a year ago will break again.

I dont think its as simple as reverting the change

I know. they this error is precisely the reverse of the previous one. Since none of this is documented how it’s supposed to work, I really have no idea what to do here… :frowning:

Which if these two projects in the test case is the problem? the .NET Core one or the .NET one?

Its the .net one.

K, that’s a lede that has been buried well for the past 17 days in this thread, as that seems to be the difference between this and the previous issue :(.

What I have done now, is for .NET only, if a reference is only resolved from ref, (and it or its parent was CopyLocal), I’ll copy it. I’m not sure if thats the correct fix since that results in a whole bunch of extra copies that sound to me like they should conflict with whats already in the regular framework, but who knows.

I now get these:

Generated Files for 'JsonNetConsoleApplication' target 'Echoes':
Echoes.dll (/Users/mh/Code/Elements/Bin/References/Echoes/NET/Echoes.dll)
Elements.dll (/Users/mh/Code/Elements/Bin/References/Echoes/NET/Elements.dll)
JsonNetConsoleApplication.exe (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/JsonNetConsoleApplication-B3E0F985FB5B468C29CD713562A17E5482D3E6BB/Debug/Echoes/JsonNetConsoleApplication.exe)
Microsoft.Bcl.AsyncInterfaces.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/microsoft.bcl.asyncinterfaces/1.1.0/lib/net461/Microsoft.Bcl.AsyncInterfaces.dll)
System.Buffers.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.buffers/4.5.0/ref/net45/System.Buffers.dll)
System.Memory.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.memory/4.5.3/lib/netstandard2.0/System.Memory.dll)
System.Numerics.Vectors.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.numerics.vectors/4.5.0/lib/net46/System.Numerics.Vectors.dll)
System.Runtime.CompilerServices.Unsafe.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.runtime.compilerservices.unsafe/4.7.1/lib/net461/System.Runtime.CompilerServices.Unsafe.dll)
System.Text.Encodings.Web.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.text.encodings.web/4.7.0/lib/netstandard2.0/System.Text.Encodings.Web.dll)
System.Text.Json.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.text.json/4.7.1/lib/net461/System.Text.Json.dll)
System.Threading.Tasks.Extensions.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.threading.tasks.extensions/4.5.2/lib/netstandard2.0/System.Threading.Tasks.Extensions.dll)
System.ValueTuple.dll (/Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/system.valuetuple/4.5.0/lib/net47/System.ValueTuple.dll

this will be in the next build.

SystemTextJson.zip (1.5 MB)

Sorry the original had a dependency on a file, this one doesnt

Im not sure about that, I had thought ref versions should never be copied.

Well, thats what was happening before. Buffers only exists in ref. I cannot “never copy ref” and still give you the copy your project seem to need. You understand my confusion, right?

oh yes :slight_smile:

When I first reported “Reference assemblies should not be loaded for execution” was it copying from lib/netstandard2.0/System.Buffers.dll ?

Yes, iirc.

the difference here is that this one is common from net45, not netstandard20. not sure if thats the distillery gushing marker? (maybe one coming from netcoreXX should also be copied? We’ll never know until we hit a case… :frowning:

Using ms tools
I created a .net core console app, added the nuget and it doesnt add it to the bin folder. I also created .net 4.7 web apps, one with system.text.json and the other with Microsoft.Azure.ServiceBus and they both had system.buffers in the bin folder

This stackoverflow post has a few more details about what the difference is

So looks like the final result we now have I good (whether for the right reasons yet, nor not :wink:

Cool, I’ll check that out, thanx!

It is used to allow .NET Standard libraries to run on partly-compatible versions of .NET Framework. It works by adding the implementation assemblies to the build output - but these are a special as they only forward to corresponding .NET Framework types and add API surface that throws PlatformNotSupportedException for types that are available in .NET Standard but not implemented by the .NET Framework. E.g. a .NET Standard 1.* library would reference System.Object from System.Runtime.dll and a .NET Standard 2.0 library would reference it from netstandard.dll . The Microsoft.NET.Build.Extensions contains both a System.Runtime.dll and a netstandard.dll that contain type forwarding declarations to forward to .NET Framework’s mscorlib.dll .

:exploding_head:

You didnt miss the bit I said its with Microsoft tools ?

Yeah Im not entirely sure what that means. Is it something the compiler has to sort out or the developer of the library ?