You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using ThisAssembly.Resources to access resources produces IL3000 warning when published for AOT compilation using .NET 8. This is caused by the following code in EmbeddedResource that gets embedded into the user project:
It looks like that this is done to give an external file preference over the embedded resource (which is a surprising behaviour that should really be opted into via some option):
Run dotnet new console to create a new console project
Run dotnet add package ThisAssembly.Resources to add a reference to the ThisAssembly.Resources package.
Add a resource to the project.
Add the <PublishAot>true</PublishAot> property to the project file.
Publish with dotnet publish -c Release -o dist
During compilation, the following warning is emitted:
ThisAssembly.Resource\ThisAssembly.ResourcesGenerator\ThisAssembly.Resources.EmbeddedResource.cs(8): warning IL3000: EmbeddedResource..cctor(): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.
Expected no warnings during dotnet publish when doing AOT compilation.
Embedded resources are unaffected by files on disk.
Of course, if the user project is treating warnings as errors then the compilation entirely fails. It is awkward, if not possible impossible, to isolate the suppression of IL3000 to just the generated code (since it doesn't technically exist on disk).
Describe the Bug
Using ThisAssembly.Resources to access resources produces IL3000 warning when published for AOT compilation using .NET 8. This is caused by the following code in
EmbeddedResource
that gets embedded into the user project:ThisAssembly/src/EmbeddedResource.cs
Line 8 in 0e5f0c4
It looks like that this is done to give an external file preference over the embedded resource (which is a surprising behaviour that should really be opted into via some option):
ThisAssembly/src/EmbeddedResource.cs
Lines 27 to 29 in 0e5f0c4
Steps to Reproduce
These steps assume .NET SDK 8 is in use.
dotnet new console
to create a new console projectdotnet add package ThisAssembly.Resources
to add a reference to the ThisAssembly.Resources package.<PublishAot>true</PublishAot>
property to the project file.dotnet publish -c Release -o dist
During compilation, the following warning is emitted:
A fully working example can be found in
ThisAssemblyApp.zip
.Expected Behavior
dotnet publish
when doing AOT compilation.Of course, if the user project is treating warnings as errors then the compilation entirely fails. It is awkward, if not possible impossible, to isolate the suppression of IL3000 to just the generated code (since it doesn't technically exist on disk).
Version Info
Using version 1.41 of the package.
Additional Info
Running
dotnet --info
prints:The text was updated successfully, but these errors were encountered: