2

I get this error when I build the code using my fork of StackExchange.Precompilation - https://github.com/MarkKharitonov/StackExchange.Precompilation

So I took it (following the advice in https://stackoverflow.com/a/71611526/80002), adjusted it to work with the most recent versions of the packages and it works well:

C:\work\StackExchange.Precompilation [master ≡]> git lg -4
e9055ed |  (HEAD -> master, origin/master, origin/HEAD) Enable convenient debugging of the precompiler. (6 minutes ago) [Kharitonov, Mark] (2022-03-26 20:04:24 -0400)
7568de6 |  Minor changes, #define SE_PRECOMPILER_INCLUDE_RAZOR automatically when necessary. (4 hours ago) [Kharitonov, Mark] (2022-03-26 15:44:05 -0400)
50349c3 |  Update the code to use the most recent packages. (7 hours ago) [Kharitonov, Mark] (2022-03-25 20:01:26 -0400)
d595fac |  sourcelink it is (3 years, 3 months ago) [sprelog] (2018-12-14 14:41:05 +0100)
C:\work\StackExchange.Precompilation [master ≡]> .\BuildAndPack.ps1 -Debug
  Determining projects to restore...
  Restored C:\work\StackExchange.Precompilation\StackExchange.Precompilation.Tests\StackExchange.Precompilation.Tests.csproj (in 592 ms).
  Restored C:\work\StackExchange.Precompilation\Test.Module\Test.Module.csproj (in 592 ms).
  Restored C:\work\StackExchange.Precompilation\Test.ConsoleApp\Test.ConsoleApp.csproj (in 592 ms).
  Restored C:\work\StackExchange.Precompilation\Test.WebApp.ExternalViews\Test.WebApp.ExternalViews.csproj (in 592 ms).
  Restored C:\work\StackExchange.Precompilation\StackExhcange.Precompilation.MVC5\StackExchange.Precompilation.MVC5.csproj (in 592 ms).
  Restored C:\work\StackExchange.Precompilation\Test.WebApp\Test.WebApp.csproj (in 592 ms).
  Restored C:\work\StackExchange.Precompilation\StackExchange.Precompilation\StackExchange.Precompilation.csproj (in 592 ms).
  Restored C:\work\StackExchange.Precompilation\StackExchange.Precompilation.Build\StackExchange.Precompilation.Build.csproj (in 592 ms).
  StackExchange.Precompilation -> C:\work\StackExchange.Precompilation\StackExchange.Precompilation\bin\Debug\net472\StackExchange.Precompilation.dll
  StackExchange.Precompilation.Build -> C:\work\StackExchange.Precompilation\StackExchange.Precompilation.Build\bin\Debug\net472\StackExchange.Precompiler.exe
  Test.Module -> C:\work\StackExchange.Precompilation\Test.Module\bin\Debug\net472\Test.Module.dll
  StackExchange.Precompilation.MVC5 -> C:\work\StackExchange.Precompilation\StackExhcange.Precompilation.MVC5\bin\Debug\net472\StackExchange.Precompilation.MVC5.dll
  Test.ConsoleApp -> C:\work\StackExchange.Precompilation\Test.ConsoleApp\bin\Debug\net472\Test.ConsoleApp.exe
  Test.WebApp.ExternalViews -> C:\work\StackExchange.Precompilation\Test.WebApp.ExternalViews\bin\Debug\net472\Test.WebApp.ExternalViews.dll
  Test.WebApp -> C:\work\StackExchange.Precompilation\Test.WebApp\bin\Test.WebApp.dll
  StackExchange.Precompilation.Tests -> C:\work\StackExchange.Precompilation\StackExchange.Precompilation.Tests\bin\Debug\net472\StackExchange.Precompilation.Tests.dll
  Successfully created package 'C:\work\StackExchange.Precompilation\packages\obj\StackExchange.Precompilation.Build.6.1.0-local1648325439.nupkg'.
  Successfully created package 'C:\work\StackExchange.Precompilation\packages\obj\StackExchange.Precompilation.6.1.0-local1648325439.nupkg'.
  Successfully created package 'C:\work\StackExchange.Precompilation\packages\obj\StackExchange.Precompilation.MVC5.6.1.0-local1648325439.nupkg'.
C:\work\StackExchange.Precompilation\Test.ConsoleApp\Program.cs
C:\work\StackExchange.Precompilation\Test.ConsoleApp\Program.cs
Test.ConsoleApp.AliasTest
C:\work\StackExchange.Precompilation [master ≡]>

I made a small change to Test.WebApp and now it fails:

C:\work\StackExchange.Precompilation [master ≡]> git co WithCommonLogging
Switched to branch 'WithCommonLogging'
Your branch is up to date with 'origin/WithCommonLogging'.
C:\work\StackExchange.Precompilation [WithCommonLogging ≡]> git lg -2
13a2c5f |  (HEAD -> WithCommonLogging, origin/WithCommonLogging) Add a test case involving Common.Logging, which depends on mscorlib 2.0.5.0 - currently breaks the build. (8 minutes ago) [Kharitonov, Mark] (2022-03-26 20:05:26 -0400)
e9055ed |  (origin/master, origin/HEAD, master) Enable convenient debugging of the precompiler. (9 minutes ago) [Kharitonov, Mark] (2022-03-26 20:04:24 -0400)
C:\work\StackExchange.Precompilation [WithCommonLogging ≡]> .\BuildAndPack.ps1 -Debug
  Determining projects to restore...
  Restored C:\work\StackExchange.Precompilation\StackExchange.Precompilation\StackExchange.Precompilation.csproj (in 585 ms).
  Restored C:\work\StackExchange.Precompilation\StackExchange.Precompilation.Tests\StackExchange.Precompilation.Tests.csproj (in 586 ms).
  Restored C:\work\StackExchange.Precompilation\Test.ConsoleApp\Test.ConsoleApp.csproj (in 586 ms).
  Restored C:\work\StackExchange.Precompilation\StackExhcange.Precompilation.MVC5\StackExchange.Precompilation.MVC5.csproj (in 586 ms).
  Restored C:\work\StackExchange.Precompilation\Test.WebApp\Test.WebApp.csproj (in 586 ms).
  Restored C:\work\StackExchange.Precompilation\Test.Module\Test.Module.csproj (in 586 ms).
  Restored C:\work\StackExchange.Precompilation\StackExchange.Precompilation.Build\StackExchange.Precompilation.Build.csproj (in 586 ms).
  Restored C:\work\StackExchange.Precompilation\Test.WebApp.ExternalViews\Test.WebApp.ExternalViews.csproj (in 585 ms).
  StackExchange.Precompilation -> C:\work\StackExchange.Precompilation\StackExchange.Precompilation\bin\Debug\net472\StackExchange.Precompilation.dll
  StackExchange.Precompilation.Build -> C:\work\StackExchange.Precompilation\StackExchange.Precompilation.Build\bin\Debug\net472\StackExchange.Precompiler.exe
  Test.Module -> C:\work\StackExchange.Precompilation\Test.Module\bin\Debug\net472\Test.Module.dll
  StackExchange.Precompilation.MVC5 -> C:\work\StackExchange.Precompilation\StackExhcange.Precompilation.MVC5\bin\Debug\net472\StackExchange.Precompilation.MVC5.dll
  Test.ConsoleApp -> C:\work\StackExchange.Precompilation\Test.ConsoleApp\bin\Debug\net472\Test.ConsoleApp.exe
  Test.WebApp.ExternalViews -> C:\work\StackExchange.Precompilation\Test.WebApp.ExternalViews\bin\Debug\net472\Test.WebApp.ExternalViews.dll
C:\work\StackExchange.Precompilation\Test.WebApp\MvcApplication.cs(29,13): error CS0012: The type 'Action<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. [C:\work\StackExchange.Precompilation\Test.WebApp\Test.WebApp.csproj]
  StackExchange.Precompilation.Tests -> C:\work\StackExchange.Precompilation\StackExchange.Precompilation.Tests\bin\Debug\net472\StackExchange.Precompilation.Tests.dll
MSBuild failed

The change is:

  1. Add NuGet reference to Common.Logging
  2. Call ILog.Info

https://github.com/MarkKharitonov/StackExchange.Precompilation/commit/13a2c5f4a27915307d0a403d1c73f0922da87ebe

And now it fails with the error message

C:\work\StackExchange.Precompilation\Test.WebApp\MvcApplication.cs(29,13): error CS0012: The type 'Action<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. [C:\work\StackExchange.Precompilation\Test.WebApp\Test.WebApp.csproj]

Now I understand that StackExchange.Precompilation copies the logic of csc.exe code from 7 years ago. Unfortunately, so far it is the best I have to replace aspnet_compiler.exe.

So my question is simple - how do we fix it?

mark
  • 59,016
  • 79
  • 296
  • 580
  • 1
    coming from the other posting... wish i could help, but dealing with .Net version complexities makes my header hurt. I hope you find the answer and of course post it here. – Elroy Flynn Mar 27 '22 at 01:22

0 Answers0