Description
Version Used: SDK 5.0.201
This has always worked when running msbuild
, but it does not work using dotnet build
. The only workaround I have at the moment is to put /p:BuildInParallel=false
in the dotnet build line which is not great because I want people to be able to walk up and type dotnet build multiple times. <BuildInParallel>false</BuildInParallel>
didn't seem to have any effect on the repro.
What would it take to get from here to things just working for consumers of analyzers that have dependencies?
Steps to Reproduce:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="PropertyChangedAnalyzers" Version="3.2.1" PrivateAssets="all" />
<PackageReference Include="ReflectionAnalyzers" Version="0.1.22-dev" PrivateAssets="all" />
</ItemGroup>
</Project>
using System.ComponentModel;
using System.Runtime.CompilerServices;
public sealed class C : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private string property1;
public string Property1 { get => property1; set => Set(ref property1, value); }
private bool Set<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
{
if (RuntimeHelpers.Equals(field, value)) return false;
field = value;
OnPropertyChanged(propertyName);
return true;
}
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
Run this (rebuild
is only to simulate edit + build during development):
for ($i = 0; $i -lt 10; $i++) { dotnet build /t:rebuild }
Expected Behavior:
No warnings.
Actual Behavior:
37 warnings appear, all analyzer crashes due to not being able to load an assembly:
CSC : warning AD0001: Analyzer 'PropertyChangedAnalyzers.PropertyDeclarationAnalyzer' threw an exception of type 'System.IO.FileLoadException' with message 'Could not load file or assembly 'Gu.Roslyn.Extensions, Version=0.12.9.0, Culture=neutral, PublicKeyToken=4b04740f2fd5868f'. Could not find or load a specific file.