Skip to content

Commit ff78421

Browse files
committed
CSScriptLib:
- Issue #343: Publish to single file gives an empty Assembly.Location which crashes Roslyn Evaluator
1 parent a92a133 commit ff78421

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

src/BuildServer/out/build.runtimeconfig.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
"framework": {
55
"name": "Microsoft.NETCore.App",
66
"version": "7.0.0"
7-
},
8-
"configProperties": {
9-
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false
107
}
118
}
129
}

src/CS-Script.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
4747
.editorconfig = .editorconfig
4848
EndProjectSection
4949
EndProject
50-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.SingleFileBuild", "CSScriptLib\src\Client.SingleFileBuild\Client.SingleFileBuild.csproj", "{ABB37908-97F9-4FEF-B63F-4785755D219D}"
50+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client.SingleFileBuild", "CSScriptLib\src\Client.SingleFileBuild\Client.SingleFileBuild.csproj", "{ABB37908-97F9-4FEF-B63F-4785755D219D}"
5151
EndProject
5252
Global
5353
GlobalSection(SolutionConfigurationPlatforms) = preSolution

src/CSScriptLib/src/Client.SingleFileBuild/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using CSScriptLib;
44
using Microsoft.CodeAnalysis;
55

6-
// dotnet publish --configuration Release --output .\publish
6+
// dotnet publish --configuration Release --output .\publish --self-contained true
77

88
// ---------------------------
99
// evaluation of a simple expression

src/cscs/Utils/ReflectionExtensions.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,16 @@ public static string Location(this Assembly asm)
190190
else
191191
return asm.Location;
192192
}
193-
catch
193+
catch (Exception ex)
194194
{
195195
#if class_lib
196196
if (Runtime.IsSingleFileApplication)
197197
return null; // a single file compilation (published with PublishSingleFile option)
198-
else
198+
else if (ex.Message.Contains("CodeBase is not supported on assemblies loaded from a single-file bundle")
199+
|| ex.StackTrace.Contains("at System.Reflection.RuntimeAssembly.get_CodeBase()"))
200+
return null;
199201
#endif
200-
throw;
202+
throw;
201203
}
202204
}
203205

0 commit comments

Comments
 (0)