logged from
Doesn't name a file, so you have to dig through more information to do anything about it.
Looks like everything in that block should list the reference in its error.
Talked with @shanselman who saw this on a machine where he'd also found several zero-byte files, which led to a nice repro:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Reference Include="deliberately.zero.bytes.dll" />
</ItemGroup>
<Target Name="WriteZeroByteFile" BeforeTargets="ResolveAssemblyReferences">
<Touch Files="deliberately.zero.bytes.dll" AlwaysCreate="true" />
</Target>
</Project>
Which leads to
$ dotnet build /flp:v=diag
Microsoft (R) Build Engine version 15.8.166+gd4e8d81a88 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 57.05 ms for S:\work\zero-byte-ref\zero-byte-ref.csproj.
C:\Program Files\dotnet\sdk\2.1.400\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Image is too small. [S:\work\zero-byte-ref\zero-byte-ref.csproj]
zero-byte-ref -> S:\work\zero-byte-ref\bin\Debug\netstandard2.0\zero-byte-ref.dll
Build succeeded.
C:\Program Files\dotnet\sdk\2.1.400\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Image is too small. [S:\work\zero-byte-ref\zero-byte-ref.csproj]
1 Warning(s)
0 Error(s)
Time Elapsed 00:00:02.44
And in the diag log
...
Primary reference "deliberately.zero.bytes.dll". (TaskId:41)
13:43:49.856 1:7>C:\Program Files\dotnet\sdk\2.1.400\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Image is too small. [S:\work\zero-byte-ref\zero-byte-ref.csproj]
Resolved file path is "S:\work\zero-byte-ref\deliberately.zero.bytes.dll". (TaskId:41)
Reference found at search path location "{RawFileName}". (TaskId:41)
For SearchPath "{CandidateAssemblyFiles}". (TaskId:41)
Considered "deliberately.zero.bytes.dll",
but its name "deliberately.zero.bytes"
didn't match the expected name "deliberately.zero.bytes.dll". (TaskId:41)
...
So there's enough information to debug _if_ you happened to up your logging level.
fyi / other context - since @shanselman also found my SO answer while researching this live on youtube (https://stackoverflow.com/questions/48122173/warning-when-using-nuget-package-that-contains-native-dll)
This also happens when native DLLs are shipped in NuGet packages since AFAIK Core MSBuild uses different APIs (?) to inspect DLLs and thus complains on native DLLs that are placed inside NuGet lib/ folders instead of runtimes/ folders.
NuGet packages did this before netstandard/netcoreapp to ship native DLLs (e.g. sql drivers, things like zeromq libs etc.). When NuGet introduced the asset target fallback to net* assemblies, this started happening a lot more.
Would be good to know which package is responsible from the error message.
Most helpful comment
Talked with @shanselman who saw this on a machine where he'd also found several zero-byte files, which led to a nice repro:
Which leads to
And in the diag log
So there's enough information to debug _if_ you happened to up your logging level.