In my case the project had an old .tt
file present in the file structure.
The .csproj
had an exclusion for showing/compiling it, e.g.:
<ItemGroup>
<Compile Remove="BaseTemplate.cs" />
</ItemGroup>
<ItemGroup>
<None Remove="BaseTemplate.tt" />
</ItemGroup>
<ItemGroup>
<Compile Update="TemplateRunner.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>TemplateRunner.tt</DependentUpon>
</Compile>
</ItemGroup>
nonetheless roslynator (in my case) would break when running against the project:
One or more errors occurred. (Cannot modify an evaluated object originating in an imported file "/home/me/.dotnet/sdk/6.0.404/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.DefaultItems.props".)
Inner exception: Cannot modify an evaluated object originating in an imported file "/home/me/.dotnet/sdk/6.0.404/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.DefaultItems.props".
Adding <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
to the .csproj
fixed my issue.
I discovered this setting via https://github.com/Testura/Testura.Mutation/issues/11