2

When I am trying to install the latest version 10.0.3 of NewtonSoft.Json I get the error

Cannot modify an evaluated object originating in an imported file ""C:\code2\<my repo>\src\DassFHLSFApp1\packages\XX.XXXX.Core.1.0.126\build\XX.XXXX.Core.props"." 

and it refers to another package's props file.

Any idea why am getting this error and how to fix this

Shubham Jain
  • 33
  • 1
  • 2

1 Answers1

0

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

user326608
  • 2,210
  • 1
  • 26
  • 33