Open mitchcapper opened 1 year ago
Your project uses PublishAot=true
which will end up using the AOT compiler (ilc
), not the illink
tool. The _TrimmerDumpDependencies
property only acts when the illink
tool is used.
You do have IlcGenerateDgmlFile
which is the equivalent functionality for the AOT compiler. This should produce a .dgml
file in obj\<Configuration>\<TFM>\<RID>\native\
. You can used the DependencyGraphViewer
tool to inspect it: https://github.com/dotnet/runtime/tree/main/src/coreclr/tools/aot/DependencyGraphViewer
Alternatively you can publish your project without AOT so /p:PublishAot=false /p:PublishTrimmed=true
in which case the illink
will be used and you will be able to use the analyzer tool from this repo.
Note that the trimming behavior between illink
and ilc
can be different, the tools have somewhat different capabilities in some areas.
Also note that the development of illink
and all of the related tools has moved to the dotnet/runtime repo.
Hrm. Still no luck. Removed the Properties folder from that sample and updated the project:
cat .\LinkerAnalyzerFail.csproj
<Project Sdk="Microsoft.NET.Sdk">
> dotnet restore
Determining projects to restore...
Restored LinkerAnalyzerFail.csproj (in 104 ms).
> msbuild /p:_TrimmerDumpDependencies=true /p:Configuration=Release /p:PublishAot=false /p:PublishTrimmed=true /t:Rebuild
LinkerAnalyzerFail -> bin\Release\net7.0-windows10.0.22621.0\win-x64\LinkerAnalyzerFail.dll Copying file from "obj\Release\net7.0-windows10.0.22621.0\win-x64\LinkerAnalyzerFail.pdb" to "bin\Release\net7.0-windows10.0.22621.0\win-x64\LinkerAnalyzerFail.pdb". Done Building Project "LinkerAnalyzerFail.csproj" (Rebuild target(s)).
Done Building Project "LinkerAnalyzerFail.sln" (Rebuild target(s)).
> find | grep -i xml
./bin/Release/net7.0-windows10.0.22621.0/win-x64/System.Private.Xml.dll ./bin/Release/net7.0-windows10.0.22621.0/win-x64/System.Private.Xml.Linq.dll ./bin/Release/net7.0-windows10.0.22621.0/win-x64/System.Runtime.Serialization.Xml.dll ./bin/Release/net7.0-windows10.0.22621.0/win-x64/System.Xml.dll ./bin/Release/net7.0-windows10.0.22621.0/win-x64/System.Xml.Linq.dll ./bin/Release/net7.0-windows10.0.22621.0/win-x64/System.Xml.ReaderWriter.dll ./bin/Release/net7.0-windows10.0.22621.0/win-x64/System.Xml.Serialization.dll ./bin/Release/net7.0-windows10.0.22621.0/win-x64/System.Xml.XDocument.dll ./bin/Release/net7.0-windows10.0.22621.0/win-x64/System.Xml.XmlDocument.dll ./bin/Release/net7.0-windows10.0.22621.0/win-x64/System.Xml.XmlSerializer.dll ./bin/Release/net7.0-windows10.0.22621.0/win-x64/System.Xml.XPath.dll ./bin/Release/net7.0-windows10.0.22621.0/win-x64/System.Xml.XPath.XDocument.dll
I am not sure where I found the link to this or the docs talking about native AOT size optimization so its possible I read it wrong or it wasn't clear one vs the other. In terms of the wrong repo I do see it at https://github.com/dotnet/runtime/tree/main/src/tools/illink/src/analyzer for this (potential) bug not sure if I should re-file it under dotnet runtime.
The instructions are only valid for Xamarin projects. For console projects the trimmer/aot only runs during publish. I opened a PR to fix the doc in the runtime repo (for the analyzer tool): https://github.com/dotnet/runtime/pull/84833
To get the linker dependencies XML usable by the analyzer tool:
dotnet publish /p:PublishTrimmed=true /p:_TrimmerDumpDependencies=true
The output is in obj/Release/net7.0-windows10.0.22621.0/win-x64/linked/linker-dependencies.xml
. This file can be consumed by the illinkanalyzer
tool.
You can also get dgml file from the illink:
dotnet publish /p:PublishTrimmed=true /p:_TrimmerDumpDependencies=true /p:_TrimmerDependenciesFileFormat=dgml
The output is now in obj\Release\net7.0-windows10.0.22621.0\win-x64\linked\linker-dependencies.dgml
.
This can be consumed by the DependencyGraphViewer
tool in https://github.com/dotnet/runtime/tree/main/src/coreclr/tools/aot/DependencyGraphViewer.
NativeAOT can only produce the dgml file:
dotnet publish /p:PublishAot=true /p:IlcGenerateDgmlFile=true
The output is going to be in obj\Release\net7.0-windows10.0.22621.0\win-x64\native\<app>.codegen.dgml.xml
(and another file called <app>.scan.dgml.xml
since the compiler does too passes on the input, so two dependency graphs).
This can be consumed by the DependencyGraphViewer
tool as well.
There's some additional details about some of this here: https://github.com/dotnet/runtime/tree/main/src/coreclr/tools/aot/DependencyGraphViewer#readme
per: https://github.com/dotnet/linker/blob/main/src/analyzer/README.md it seems like this should work for .net SDK style projects but I am having no luck.
I created a simple repro test case and built it using
msbuild /p:_TrimmerDumpDependencies=true /p:Configuration=Release /t:Rebuild
but no linker xml file is generated. Attached is the project and the build output. LinkerAnalyzerFail.zip msbuild_output.txt