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
Obtaining a list of runtime libraries via DependencyContext.Default.RuntimeLibraries returns a list that includes non-runtime libraries such as code analyzers, custom MSBuild task assemblies, etc.
Starting from a basic dotnet new console app (.net 9) ...
I added these references:
usingMicrosoft.Extensions.DependencyModel;varruntimeLibraries=DependencyContext.Default?.RuntimeLibraries;if(runtimeLibraries!=null){varcodeAnalyzerIsRuntimeLibrary=runtimeLibraries.Any(r =>r.Name.Contains("SonarAnalyzer"));if(codeAnalyzerIsRuntimeLibrary)thrownewInvalidOperationException("SonarAnalyzer should NOT be considered as a runtime library.");}
The exception is always thrown.
The code analyzer assembly is NOT being copied to the output folder (which is good and correct).
But the code analyzer assembly IS being included in the .deps.json file (which I don't think is right).
.NET SDK:
Version: 9.0.300
Commit: 15606fe0a8
Workload version: 9.0.300-manifests.af4147de
MSBuild version: 17.14.5+edd3bbf37
Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.300\