cs-script: Publish to single file gives an empty Assembly.Location which crashes Roslyn Evaluator
I’m running a .NET 7 WPF app with a reference to CSScriptLib nuget.
My project works great and scripts run right in debug mode. When I publish I get the error:
“Current version of Roslyn-based evaluator does not support referencing assemblies which are not loaded from the file location.”
I publish to a single file which merges most of the referenced dlls into a single dll. Looks like this code in Evaluator.Roslyn.cs is having a problem with it:
public override IEvaluator ReferenceAssembly(Assembly assembly)
{
//Microsoft.Net.Compilers.1.2.0 - beta
if (assembly.Location.IsEmpty())
I checked this in my code when publishing both to many files and to a single file and in the latter case Location is empty.
if (string.IsNullOrEmpty(typeof(IRunScriptAsync).Assembly.Location))
throw new System.Exception("Assembly.Location is empty");
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Comments: 22 (13 by maintainers)
Commits related to this issue
- CS-ScriptLib: - Issue #343: Publish to single file gives an empty Assembly.Location which crashes Roslyn Evaluator — committed to oleg-shilo/cs-script by oleg-shilo 9 months ago
- # Release v4.8.3.0 - Issue #343: Publish to single file gives an empty Assembly.Location which crashes Roslyn Evaluator - Added support for single-file published host applications — committed to oleg-shilo/cs-script by oleg-shilo 9 months ago
- CSScriptLib: - Issue #343: Publish to single file gives an empty Assembly.Location which crashes Roslyn Evaluator — committed to oleg-shilo/cs-script by oleg-shilo 9 months ago
- Pre-Release v4.8.4-pre --- ## Changes ### CLI - no changes ### CSScriptLib - Issue #343: Publish to single file gives an empty Assembly.Location which crashes Roslyn Evaluator Added support fo... — committed to oleg-shilo/cs-script by oleg-shilo 9 months ago
It works! Amazing thank you.
dotnet publish -c Release --no-self-containedSorry for the confusion, I am using your project and yes it does work in self contained mode. The problem arises when deployed as Framework dependent, or self-contained = false.
I have always used Framework dependent deployments, due to a smaller file size, but I’m thinking self-contained does have benefits, and the bandwidth is not such a big deal these days. So deploying self-contained as the solution is not a problem.