@@ -13,7 +13,7 @@ namespace Dotnet.Script.Core
13
13
{
14
14
public class ScriptPublisher
15
15
{
16
- private const string ScriptingVersion = "2.8.2 " ;
16
+ private const string ScriptingVersion = "3.7.0 " ;
17
17
18
18
private readonly ScriptProjectProvider _scriptProjectProvider ;
19
19
private readonly ScriptEmitter _scriptEmitter ;
@@ -70,18 +70,11 @@ public void CreateExecutable<TReturn, THost>(ScriptContext context, LogFactory l
70
70
throw new ArgumentNullException ( nameof ( runtimeIdentifier ) ) ;
71
71
}
72
72
73
- string targetFrameworkFolder = _scriptEnvironment . TargetFramework ;
74
- if ( string . Equals ( targetFrameworkFolder , "netcoreapp5.0" , StringComparison . InvariantCultureIgnoreCase ) )
75
- {
76
- targetFrameworkFolder = "net5.0" ;
77
- }
78
-
79
-
80
73
executableFileName = executableFileName ?? Path . GetFileNameWithoutExtension ( context . FilePath ) ;
81
74
const string AssemblyName = "scriptAssembly" ;
82
75
83
- var tempProjectPath = ScriptProjectProvider . GetPathToProjectFile ( Path . GetDirectoryName ( context . FilePath ) , targetFrameworkFolder ) ;
84
- var renamedProjectPath = ScriptProjectProvider . GetPathToProjectFile ( Path . GetDirectoryName ( context . FilePath ) , targetFrameworkFolder , executableFileName ) ;
76
+ var tempProjectPath = ScriptProjectProvider . GetPathToProjectFile ( Path . GetDirectoryName ( context . FilePath ) , _scriptEnvironment . TargetFramework ) ;
77
+ var renamedProjectPath = ScriptProjectProvider . GetPathToProjectFile ( Path . GetDirectoryName ( context . FilePath ) , _scriptEnvironment . TargetFramework , executableFileName ) ;
85
78
var tempProjectDirectory = Path . GetDirectoryName ( tempProjectPath ) ;
86
79
87
80
var scriptAssemblyPath = CreateScriptAssembly < TReturn , THost > ( context , tempProjectDirectory , AssemblyName ) ;
@@ -95,7 +88,10 @@ public void CreateExecutable<TReturn, THost>(ScriptContext context, LogFactory l
95
88
96
89
var commandRunner = new CommandRunner ( logFactory ) ;
97
90
// todo: may want to add ability to return dotnet.exe errors
98
- var exitcode = commandRunner . Execute ( "dotnet" , $ "publish \" { renamedProjectPath } \" -c Release -r { runtimeIdentifier } -o \" { context . WorkingDirectory } \" { ( ScriptEnvironment . Default . NetCoreVersion . Major >= 3 ? "/p:PublishSingleFile=true" : string . Empty ) } /p:DebugType=Embedded") ;
91
+ var publishSingleFileArgument = ScriptEnvironment . Default . NetCoreVersion . Major >= 3 ? "/p:PublishSingleFile=true" : string . Empty ;
92
+ var includeNativeLibrariesForSelfExtract = ScriptEnvironment . Default . NetCoreVersion . Major >= 5 ? "/p:IncludeNativeLibrariesForSelfExtract=true" : string . Empty ;
93
+
94
+ var exitcode = commandRunner . Execute ( "dotnet" , $ "publish \" { renamedProjectPath } \" -c Release -r { runtimeIdentifier } -o \" { context . WorkingDirectory } \" { publishSingleFileArgument } { includeNativeLibrariesForSelfExtract } /p:DebugType=Embedded") ;
99
95
100
96
if ( exitcode != 0 )
101
97
{
@@ -107,7 +103,7 @@ public void CreateExecutable<TReturn, THost>(ScriptContext context, LogFactory l
107
103
108
104
private string CreateScriptAssembly < TReturn , THost > ( ScriptContext context , string outputDirectory , string assemblyFileName )
109
105
{
110
- var emitResult = _scriptEmitter . Emit < TReturn , THost > ( context ) ;
106
+ var emitResult = _scriptEmitter . Emit < TReturn , THost > ( context , assemblyFileName ) ;
111
107
var assemblyPath = Path . Combine ( outputDirectory , $ "{ assemblyFileName } .dll") ;
112
108
using ( var peFileStream = new FileStream ( assemblyPath , FileMode . Create ) )
113
109
using ( emitResult . PeStream )
0 commit comments