unoptimized-assembly-detector
unoptimized-assembly-detector copied to clipboard
Dependency Issue
No dice first time I tried this. Build works fine without this package referenced. .Net Core 3.1 Windows 10
9>Failed checking if assembly is optimized: D:.nuget\packages\amazon.aspnetcore.dataprotection.ssm\2.1.0\lib\netstandard2.0\Amazon.AspNetCore.DataProtection.SSM.dll 9>D:.nuget\packages\unoptimizedassemblydetector\0.1.1\build\UnoptimizedAssemblyDetector.targets(14,5): error MSB4018: The "DetectUnoptimizedAssembly" task failed unexpectedly. 9>D:.nuget\packages\unoptimizedassemblydetector\0.1.1\build\UnoptimizedAssemblyDetector.targets(14,5): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'System.Reflection.Metadata, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. 9>D:.nuget\packages\unoptimizedassemblydetector\0.1.1\build\UnoptimizedAssemblyDetector.targets(14,5): error MSB4018: File name: 'System.Reflection.Metadata, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 9>D:.nuget\packages\unoptimizedassemblydetector\0.1.1\build\UnoptimizedAssemblyDetector.targets(14,5): error MSB4018: at UnoptimizedAssemblyDetector.DetectUnoptimizedAssembly.CheckAssemblyIsOptimized(String assemblyPath, String file) 9>D:.nuget\packages\unoptimizedassemblydetector\0.1.1\build\UnoptimizedAssemblyDetector.targets(14,5): error MSB4018: at UnoptimizedAssemblyDetector.DetectUnoptimizedAssembly.Execute() in /_/src/UnoptimizedAssemblyDetector/DetectUnoptimizedAssembly.cs:line 81 9>D:.nuget\packages\unoptimizedassemblydetector\0.1.1\build\UnoptimizedAssemblyDetector.targets(14,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 9>D:.nuget\packages\unoptimizedassemblydetector\0.1.1\build\UnoptimizedAssemblyDetector.targets(14,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Thanks for raising this @ADCJustinH .
Is it possible to share a repro so I can debug it?
Are you running this within Visual Studio? Does it work through the CLI (like dotnet build -c Release) ?
It's relevant because Visual Studio runs MSBuilds through .NET Framework where dotnet build will run with CoreCLR.
This package is shipped with 2 targets, one for Core and one for Framework. Both of which depend on System.Reflection.Metadata, Version=5.0.0.0 but I suspect this will be a .NET Framework (binding redirect?) issue.
I suspect the problem is you are in a shared appdomain that you dont own. if any other task loads a diff version of Metadata before you, then it will break. u should probably ilmerge or spawn a new appdomain
actually you dont bundle System.Reflection.Metadata in the package. so how is it meant to find it?
It's defined as a package reference: https://github.com/bruno-garcia/unoptimized-assembly-detector/blob/6e75ec3e26afff98ad371908fdd78af8edc7fed9/src/UnoptimizedAssemblyDetector/UnoptimizedAssemblyDetector.csproj#L57
Are you saying this isn't being loaded like this and it just works by coincidence? :)
i didnt think package references worked for msbuild tasks. at least that was my experience when building Fody. that might have changed.
and for me this project never works. for my contributions to sentry i had to comment it out and avoid checking that file in
i didnt think package references worked for msbuild tasks. at least that was my experience when building Fody. that might have changed.
It might then be working by coincidence.
and for me this project never works. for my contributions to sentry i had to comment it out and avoid checking that file in
This is odd. It works for me and other contributors. I've also used in other projects. By any chance can you share what is the error you get when you try to contribute to Sentry? I'd like to fix this package.