@@ -83,11 +83,16 @@ public ICompilation GetFunctionCompilation(FunctionMetadata functionMetadata)
83
83
84
84
FSharpErrorInfo [ ] errors = null ;
85
85
FSharpOption < Assembly > assemblyOption = null ;
86
- string scriptFilePath = Path . Combine ( Path . GetTempPath ( ) , Path . GetFileName ( functionMetadata . ScriptFile ) ) ;
87
86
88
- var asmName = FunctionAssemblyLoader . GetAssemblyNameFromMetadata ( functionMetadata , compilation . AssemblyName ) ;
89
- var dllName = Path . GetTempPath ( ) + asmName + ".dll" ;
90
- var pdbName = Path . ChangeExtension ( dllName , "pdb" ) ;
87
+ string scriptPath = Path . Combine ( Path . GetTempPath ( ) , Guid . NewGuid ( ) . ToString ( ) ) ;
88
+
89
+ Directory . CreateDirectory ( scriptPath ) ;
90
+
91
+ string scriptFilePath = Path . Combine ( scriptPath , Path . GetFileName ( functionMetadata . ScriptFile ) ) ;
92
+
93
+ var assemblyName = FunctionAssemblyLoader . GetAssemblyNameFromMetadata ( functionMetadata , compilation . AssemblyName ) ;
94
+ var assemblyFileName = Path . Combine ( scriptPath , assemblyName + ".dll" ) ;
95
+ var pdbName = Path . ChangeExtension ( assemblyFileName , "pdb" ) ;
91
96
92
97
try
93
98
{
@@ -112,7 +117,6 @@ public ICompilation GetFunctionCompilation(FunctionMetadata functionMetadata)
112
117
113
118
var otherFlags = new List < string > ( ) ;
114
119
115
- // For some reason CompileToDynamicAssembly wants "fsc.exe" as the first arg, it is ignored.
116
120
otherFlags . Add ( "fsc.exe" ) ;
117
121
118
122
// The --noframework option is used because we will shortly add references to mscorlib and FSharp.Core
@@ -159,7 +163,7 @@ public ICompilation GetFunctionCompilation(FunctionMetadata functionMetadata)
159
163
otherFlags . Add ( "--lib:" + Path . Combine ( Path . GetDirectoryName ( functionMetadata . ScriptFile ) , DotNetConstants . PrivateAssembliesFolderName ) ) ;
160
164
}
161
165
162
- otherFlags . Add ( "--out:" + dllName ) ;
166
+ otherFlags . Add ( "--out:" + assemblyFileName ) ;
163
167
164
168
// Get the #load closure
165
169
FSharpChecker checker = FSharpChecker . Create ( null , null , null , msbuildEnabled : FSharpOption < bool > . Some ( false ) ) ;
@@ -183,7 +187,7 @@ public ICompilation GetFunctionCompilation(FunctionMetadata functionMetadata)
183
187
184
188
if ( code == 0 )
185
189
{
186
- var assemblyBytes = File . ReadAllBytes ( dllName ) ;
190
+ var assemblyBytes = File . ReadAllBytes ( assemblyFileName ) ;
187
191
byte [ ] pdbBytes = null ;
188
192
if ( File . Exists ( pdbName ) )
189
193
{
@@ -195,7 +199,7 @@ public ICompilation GetFunctionCompilation(FunctionMetadata functionMetadata)
195
199
}
196
200
finally
197
201
{
198
- Task . WhenAll ( DeleteIfExistsAsync ( scriptFilePath ) , DeleteIfExistsAsync ( dllName ) , DeleteIfExistsAsync ( pdbName ) )
202
+ DeleteDirectoryAsync ( scriptPath , recursive : true )
199
203
. ContinueWith ( t => t . Exception . Handle ( e =>
200
204
{
201
205
// TODO: Trace
0 commit comments