Редактиране

Споделяне чрез


IL3000: Avoid accessing Assembly file path when publishing as a single file

Value
Rule ID IL3000
Category SingleFile
Fix is breaking or nonbreaking Nonbreaking

Cause

When you publish an app as a single file (for example, by setting the PublishSingleFile property to true in a project), calling the Assembly.Location property for assemblies embedded inside the single-file bundle always returns an empty string.

How to fix violations

If the app only needs the containing directory for the single-file bundle, consider using the AppContext.BaseDirectory property instead. Otherwise, consider removing the call entirely.

When to suppress warnings

It's appropriate to silence this warning if the assembly being accessed is definitely not in the single-file bundle. The assembly might not be in the bundle if the assembly is loaded dynamically from a file path.