I tried the example in this link: (Target .NET 5) https://learn.microsoft.com/en-us/dotnet/api/system.codedom.compiler.compilerparameters?view=net-5.0
but it throws PlatformNotSupportedException
exception in this line:
// Invoke compilation.
CompilerResults cr = provider.CompileAssemblyFromFile(cp, sourceFile);
Any suggestion to make it works?