Skip to content

Commit 636a3a2

Browse files
committed
# 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
1 parent 4ecd8af commit 636a3a2

File tree

14 files changed

+162
-162
lines changed

14 files changed

+162
-162
lines changed

help.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
C# Script execution engine (.NET Core). Version 4.8.2.0.
1+
C# Script execution engine (.NET Core). Version 4.8.3.0.
22
Copyright (C) 2004-2020 Oleg Shilo.
33

44

src/BuildServer/out/build.runtimeconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"framework": {
55
"name": "Microsoft.NETCore.App",
66
"version": "7.0.0"
7+
},
8+
"configProperties": {
9+
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false
710
}
811
}
912
}
Lines changed: 112 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,120 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
3-
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
<AssemblyName>CSScriptLib</AssemblyName>
6-
<PackageId>CS-Script</PackageId>
7-
<!--<NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>-->
8-
<!--<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>-->
9-
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
10-
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
11-
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
12-
<PublishRepositoryUrl>true</PublishRepositoryUrl>
13-
<IncludeSymbols>true</IncludeSymbols>
14-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
15-
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
16-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
17-
<Version>4.8.2.0</Version>
18-
<Authors>Oleg Shilo</Authors>
19-
<Description>CS-Script engine Class Library for .NET 5 (and higher)</Description>
20-
<Copyright>(C) 2018-2022 Oleg Shilo</Copyright>
21-
<PackageLicenseUrl></PackageLicenseUrl>
22-
<PackageProjectUrl>https://github.com/oleg-shilo/cs-script</PackageProjectUrl>
23-
<PackageIconUrl></PackageIconUrl>
24-
<RepositoryUrl>https://github.com/oleg-shilo/cs-script.git</RepositoryUrl>
25-
<RepositoryType>Git</RepositoryType>
26-
<PackageTags>C#, scripting, script, dynamic, .NET. .NET Core</PackageTags>
27-
<PackageReleaseNotes>
28-
---
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<AssemblyName>CSScriptLib</AssemblyName>
6+
<PackageId>CS-Script</PackageId>
7+
<!--<NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>-->
8+
<!--<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>-->
9+
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
10+
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
11+
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
12+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
13+
<IncludeSymbols>true</IncludeSymbols>
14+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
15+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
16+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
17+
<Version>4.8.3.0</Version>
18+
<Authors>Oleg Shilo</Authors>
19+
<Description>CS-Script engine Class Library for .NET 5 (and higher)</Description>
20+
<Copyright>(C) 2018-2022 Oleg Shilo</Copyright>
21+
<PackageLicenseUrl></PackageLicenseUrl>
22+
<PackageProjectUrl>https://github.com/oleg-shilo/cs-script</PackageProjectUrl>
23+
<PackageIconUrl></PackageIconUrl>
24+
<RepositoryUrl>https://github.com/oleg-shilo/cs-script.git</RepositoryUrl>
25+
<RepositoryType>Git</RepositoryType>
26+
<PackageTags>C#, scripting, script, dynamic, .NET. .NET Core</PackageTags>
27+
<PackageReleaseNotes>---
2928

30-
## Changes
29+
## Changes
3130

32-
### CLI
31+
### CLI
3332

34-
- Issue #336 (further optimization)
33+
- Issue #336 (further optimization)
3534

36-
### CSScriptLib
35+
### CSScriptLib
3736

38-
- no changes
39-
</PackageReleaseNotes>
40-
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
41-
<AssemblyVersion>4.8.2.0</AssemblyVersion>
42-
<FileVersion>4.8.2.0</FileVersion>
43-
<PackageLicenseExpression>MIT</PackageLicenseExpression>
44-
<PackageIcon>css_logo.png</PackageIcon>
45-
</PropertyGroup>
46-
<ItemGroup>
47-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
48-
</ItemGroup>
49-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
50-
<DocumentationFile>CSScriptLib.xml</DocumentationFile>
51-
<PlatformTarget>AnyCPU</PlatformTarget>
52-
<DefineConstants>TRACE;class_lib</DefineConstants>
53-
</PropertyGroup>
54-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
55-
<DocumentationFile>CSScriptLib.xml</DocumentationFile>
56-
<DefineConstants>TRACE;class_lib</DefineConstants>
57-
</PropertyGroup>
58-
<ItemGroup>
59-
<Compile Remove="CSScriptLib.Eval.CodeDom.cs" />
60-
<Compile Remove="output\aggregate.cs" />
61-
<Compile Remove="output\Test.cs" />
62-
<Compile Remove="sample.cs" />
63-
<Compile Remove="samples.cs" />
64-
</ItemGroup>
65-
<ItemGroup>
66-
<None Remove="nuget-samples.cmd" />
67-
</ItemGroup>
68-
<ItemGroup>
69-
<Compile Include="..\..\..\cscs\CodeDom\CompilerResults.cs" Link="CodeDom\CompilerResults.cs" />
70-
<Compile Include="..\..\..\cscs\CodeDom\CompilerError.cs" Link="CodeDom\CompilerError.cs" />
71-
<Compile Include="..\..\..\cscs\fileparser.cs" Link="fileparser.cs" />
72-
<Compile Include="..\..\..\cscs\Project.cs" Link="Project.cs" />
73-
<Compile Include="..\..\..\cscs\ScriptParser.cs" Link="ScriptParser.cs" />
74-
<Compile Include="..\..\..\cscs\ScriptParsingResult.cs" Link="ScriptParsingResult.cs" />
75-
<Compile Include="..\..\..\cscs\Utils\CoreExtensions.cs" Link="Utils\CoreExtensions.cs" />
76-
<Compile Include="..\..\..\cscs\Utils\CurrentDirGuard.cs" Link="Utils\CurrentDirGuard.cs" />
77-
<Compile Include="..\..\..\cscs\Utils\LinqExtensions.cs" Link="Utils\LinqExtensions.cs" />
78-
<Compile Include="..\..\..\cscs\Utils\PathExtensions.cs" Link="Utils\PathExtensions.cs" />
79-
<Compile Include="..\..\..\cscs\Utils\Globals.cs" Link="Utils\Globals.cs" />
80-
<Compile Include="..\..\..\cscs\Utils\Profiler.cs" Link="Profiler.cs" />
81-
<Compile Include="..\..\..\cscs\Utils\ReflectionExtensions.cs" Link="Utils\ReflectionExtensions.cs" />
82-
<Compile Include="..\..\..\cscs\Utils\Runtime.cs" Link="Utils\Runtime.cs" />
83-
<Compile Include="..\..\..\cscs\Utils\SimpleAsmProbing.cs" Link="SimpleAsmProbing.cs" />
84-
<Compile Include="..\..\..\cscs\Utils\SocketExtensions.cs" Link="SocketExtensions.cs" />
85-
<Compile Include="..\..\..\cscs\Utils\StringExtensions.cs" Link="Utils\StringExtensions.cs" />
86-
<Compile Include="..\..\..\cscs\Utils\WildCardExtensions.cs" Link="Utils\WildCardExtensions.cs" />
87-
</ItemGroup>
88-
<ItemGroup>
89-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.1.0" />
90-
<PackageReference Include="Microsoft.CodeAnalysis.Scripting.Common" Version="4.1.0" />
91-
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
92-
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="6.0.0" />
93-
</ItemGroup>
94-
<ItemGroup>
95-
<None Include="..\..\..\logo\css_logo.png">
96-
<Pack>True</Pack>
97-
<PackagePath></PackagePath>
98-
</None>
99-
<None Include="samples.cs" />
100-
</ItemGroup>
101-
<ItemGroup>
102-
<Folder Include="CodeDom\" />
103-
</ItemGroup>
104-
<ItemGroup>
105-
<Compile Update="Properties\Resources.Designer.cs">
106-
<DependentUpon>Resources.resx</DependentUpon>
107-
<DesignTime>True</DesignTime>
108-
<AutoGen>True</AutoGen>
109-
</Compile>
110-
</ItemGroup>
111-
<ItemGroup>
112-
<EmbeddedResource Update="Properties\Resources.resx">
113-
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
114-
<Generator>ResXFileCodeGenerator</Generator>
115-
<CustomToolNamespace>CSScripting</CustomToolNamespace>
116-
</EmbeddedResource>
117-
</ItemGroup>
118-
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
119-
<Exec Command="IF exist &quot;$(ProjectDir)out&quot; ( echo . ) ELSE ( md &quot;$(ProjectDir)out&quot;)&#xD;&#xA;&#xD;&#xA;copy &quot;$(TargetDir)$(TargetFileName)&quot; &quot;$(ProjectDir)output\$(TargetFileName)&quot;&#xD;&#xA;copy &quot;$(TargetDir)$(ProjectName).xml&quot; &quot;$(ProjectDir)output\$(ProjectName).xml&quot;&#xD;&#xA;rem copy &quot;$(ProjectDir)..\..\src\CSScriptLib.Client\Test.cs&quot; &quot;$(ProjectDir)output\Test.cs&quot;&#xD;&#xA;rem copy &quot;$(ProjectDir)..\..\src\CSScriptLib.Client\Test.cs&quot; &quot;$(ProjectDir)bin\$(ConfigurationName)\Test.cs&quot;&#xD;&#xA;&#xD;&#xA;" />
120-
</Target>
37+
- Issue #343: Publish to single file gives an empty Assembly.Location which crashes Roslyn Evaluator
38+
- Added support for single-file published host applications</PackageReleaseNotes>
39+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
40+
<AssemblyVersion>4.8.3.0</AssemblyVersion>
41+
<FileVersion>4.8.3.0</FileVersion>
42+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
43+
<PackageIcon>css_logo.png</PackageIcon>
44+
</PropertyGroup>
45+
<ItemGroup>
46+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
47+
</ItemGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
49+
<DocumentationFile>CSScriptLib.xml</DocumentationFile>
50+
<PlatformTarget>AnyCPU</PlatformTarget>
51+
<DefineConstants>TRACE;class_lib</DefineConstants>
52+
</PropertyGroup>
53+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
54+
<DocumentationFile>CSScriptLib.xml</DocumentationFile>
55+
<DefineConstants>TRACE;class_lib</DefineConstants>
56+
</PropertyGroup>
57+
<ItemGroup>
58+
<Compile Remove="CSScriptLib.Eval.CodeDom.cs" />
59+
<Compile Remove="output\aggregate.cs" />
60+
<Compile Remove="output\Test.cs" />
61+
<Compile Remove="sample.cs" />
62+
<Compile Remove="samples.cs" />
63+
</ItemGroup>
64+
<ItemGroup>
65+
<None Remove="nuget-samples.cmd" />
66+
</ItemGroup>
67+
<ItemGroup>
68+
<Compile Include="..\..\..\cscs\CodeDom\CompilerResults.cs" Link="CodeDom\CompilerResults.cs" />
69+
<Compile Include="..\..\..\cscs\CodeDom\CompilerError.cs" Link="CodeDom\CompilerError.cs" />
70+
<Compile Include="..\..\..\cscs\fileparser.cs" Link="fileparser.cs" />
71+
<Compile Include="..\..\..\cscs\Project.cs" Link="Project.cs" />
72+
<Compile Include="..\..\..\cscs\ScriptParser.cs" Link="ScriptParser.cs" />
73+
<Compile Include="..\..\..\cscs\ScriptParsingResult.cs" Link="ScriptParsingResult.cs" />
74+
<Compile Include="..\..\..\cscs\Utils\CoreExtensions.cs" Link="Utils\CoreExtensions.cs" />
75+
<Compile Include="..\..\..\cscs\Utils\CurrentDirGuard.cs" Link="Utils\CurrentDirGuard.cs" />
76+
<Compile Include="..\..\..\cscs\Utils\LinqExtensions.cs" Link="Utils\LinqExtensions.cs" />
77+
<Compile Include="..\..\..\cscs\Utils\PathExtensions.cs" Link="Utils\PathExtensions.cs" />
78+
<Compile Include="..\..\..\cscs\Utils\Globals.cs" Link="Utils\Globals.cs" />
79+
<Compile Include="..\..\..\cscs\Utils\Profiler.cs" Link="Profiler.cs" />
80+
<Compile Include="..\..\..\cscs\Utils\ReflectionExtensions.cs" Link="Utils\ReflectionExtensions.cs" />
81+
<Compile Include="..\..\..\cscs\Utils\Runtime.cs" Link="Utils\Runtime.cs" />
82+
<Compile Include="..\..\..\cscs\Utils\SimpleAsmProbing.cs" Link="SimpleAsmProbing.cs" />
83+
<Compile Include="..\..\..\cscs\Utils\SocketExtensions.cs" Link="SocketExtensions.cs" />
84+
<Compile Include="..\..\..\cscs\Utils\StringExtensions.cs" Link="Utils\StringExtensions.cs" />
85+
<Compile Include="..\..\..\cscs\Utils\WildCardExtensions.cs" Link="Utils\WildCardExtensions.cs" />
86+
</ItemGroup>
87+
<ItemGroup>
88+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.1.0" />
89+
<PackageReference Include="Microsoft.CodeAnalysis.Scripting.Common" Version="4.1.0" />
90+
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
91+
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="6.0.0" />
92+
</ItemGroup>
93+
<ItemGroup>
94+
<None Include="..\..\..\logo\css_logo.png">
95+
<Pack>True</Pack>
96+
<PackagePath></PackagePath>
97+
</None>
98+
<None Include="samples.cs" />
99+
</ItemGroup>
100+
<ItemGroup>
101+
<Folder Include="CodeDom\" />
102+
</ItemGroup>
103+
<ItemGroup>
104+
<Compile Update="Properties\Resources.Designer.cs">
105+
<DependentUpon>Resources.resx</DependentUpon>
106+
<DesignTime>True</DesignTime>
107+
<AutoGen>True</AutoGen>
108+
</Compile>
109+
</ItemGroup>
110+
<ItemGroup>
111+
<EmbeddedResource Update="Properties\Resources.resx">
112+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
113+
<Generator>ResXFileCodeGenerator</Generator>
114+
<CustomToolNamespace>CSScripting</CustomToolNamespace>
115+
</EmbeddedResource>
116+
</ItemGroup>
117+
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
118+
<Exec Command="IF exist &quot;$(ProjectDir)out&quot; ( echo . ) ELSE ( md &quot;$(ProjectDir)out&quot;)&#xD;&#xA;&#xD;&#xA;copy &quot;$(TargetDir)$(TargetFileName)&quot; &quot;$(ProjectDir)output\$(TargetFileName)&quot;&#xD;&#xA;copy &quot;$(TargetDir)$(ProjectName).xml&quot; &quot;$(ProjectDir)output\$(ProjectName).xml&quot;&#xD;&#xA;rem copy &quot;$(ProjectDir)..\..\src\CSScriptLib.Client\Test.cs&quot; &quot;$(ProjectDir)output\Test.cs&quot;&#xD;&#xA;rem copy &quot;$(ProjectDir)..\..\src\CSScriptLib.Client\Test.cs&quot; &quot;$(ProjectDir)bin\$(ConfigurationName)\Test.cs&quot;&#xD;&#xA;&#xD;&#xA;" />
119+
</Target>
121120
</Project>

src/CSScriptLib/src/CSScriptLib/Evaluator.Roslyn.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,8 @@ void add_code(string file, string[] codeLines, int lineOffset)
448448

449449
////////////////////////////////////////
450450

451+
// PrepareRefAssemblies just updates CompilerSettings.MetadataReferences
452+
// however SourceCodeKind.Script will require completely different referencing mechanizm
451453
if (info == null || info.CodeKind != SourceCodeKind.Script)
452454
PrepareRefAssemblies();
453455

@@ -482,11 +484,8 @@ void add_code(string file, string[] codeLines, int lineOffset)
482484

483485
var references = new List<MetadataReference>();
484486

485-
// foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
486-
// refAssemblies
487-
// var ttt = this.GetReferencedAssemblies();
488-
var refs = AppDomain.CurrentDomain.GetAssemblies();
489-
var explicitRefs = this.refAssemblies.Except(refs);
487+
var refs = AppDomain.CurrentDomain.GetAssemblies(); // from appdomain
488+
var explicitRefs = this.refAssemblies.Except(refs); // from code
490489
foreach (var asm in refs.Concat(explicitRefs))
491490
{
492491
unsafe
@@ -668,8 +667,6 @@ public override IEvaluator ReferenceAssembly(Assembly assembly)
668667
/// Note <see cref="IEvaluator.Eval" /> compiles and executes the script in the current AppDoman.
669668
/// All AppDomain loaded assemblies of the AppDomain being referenced from the script regardless of
670669
/// <see cref="EvaluatorConfig.ReferenceDomainAssemblies"></see> setting.
671-
/// Any other assemblies referenced via evaluator (e.g. <see cref="IEvaluator.ReferenceAssembly(Assembly)" />)
672-
/// will be ignored.
673670
/// </remarks>
674671
/// <para>This method is the only option that supports script execution for applications published with
675672
/// PublishSingleFile option.</para>

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
// evaluation of a complex script
1616
var calc = CSScript.Evaluator
1717
.Eval(@"using System;
18-
public class Script
19-
{
20-
public int Sum(int a, int b)
21-
{
22-
return a+b;
23-
}
24-
}
25-
return new Script();");
18+
public class Script
19+
{
20+
public int Sum(int a, int b)
21+
{
22+
return a+b;
23+
}
24+
}
25+
return new Script();");
2626

2727
int sum = calc.Sum(1, 2);
2828
Console.WriteLine(sum);

src/cscs/NuGet.Core.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
using CSScripting;
2+
using CSScripting.CodeDom;
3+
using Microsoft.CodeAnalysis.Scripting;
14
using System;
25
using System.Collections.Generic;
36
using System.Diagnostics;
4-
using static System.Environment;
57
using System.IO;
68
using System.Linq;
79
using System.Threading.Tasks;
810
using System.Xml.Linq;
9-
using Microsoft.CodeAnalysis.Scripting;
10-
using CSScripting;
11-
using CSScripting.CodeDom;
11+
using static System.Environment;
1212

1313
namespace csscript
1414
{
@@ -36,7 +36,7 @@ static public string NuGetExeView
3636

3737
static public bool newPackageWasInstalled => NuGetCore.NewPackageWasInstalled;
3838

39-
[Obsolete("Not to be used with new NuGet support algorithm")]
39+
[Obsolete("Not to be used with new NuGet support algorithm", true)]
4040
static public void InstallPackage(string packageNameMask, string nugetConfig = null) => NuGetCore.InstallPackage(packageNameMask, nugetConfig);
4141

4242
static public void ListPackages()

src/cscs/Utils/Utils.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@
3030

3131
#endregion Licence...
3232

33+
using csscript;
34+
using CSScripting.CodeDom;
35+
using CSScriptLib;
3336
using System;
3437
using System.Collections;
3538
using System.Collections.Generic;
3639
using System.Diagnostics;
37-
using static System.Environment;
3840
using System.Globalization;
3941
using System.IO;
4042
using System.Linq;
@@ -43,9 +45,7 @@
4345
using System.Text;
4446
using System.Text.RegularExpressions;
4547
using System.Threading;
46-
using csscript;
47-
using CSScripting.CodeDom;
48-
using CSScriptLib;
48+
using static System.Environment;
4949

5050
namespace CSScripting
5151
{
@@ -942,9 +942,7 @@ static internal int ParseAppArgs(this IScriptExecutor executor, string[] args)
942942
}
943943
else
944944
{
945-
if (argValue.NotEmpty())
946-
NuGet.InstallPackage(argValue);
947-
else
945+
if (argValue.IsEmpty())
948946
NuGet.ListPackages();
949947
CLIExitRequest.Throw();
950948
}

0 commit comments

Comments
 (0)