You've already forked linux-packaging-mono
Imported Upstream version 4.3.2.467
Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
@@ -484,6 +484,9 @@ namespace System.Workflow.ComponentModel.Compiler
|
||||
if (files == null)
|
||||
throw new ArgumentNullException("files");
|
||||
|
||||
string createdDirectoryName = null;
|
||||
string createdTempFileName = null;
|
||||
|
||||
AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
|
||||
setup.LoaderOptimization = LoaderOptimization.MultiDomainHost;
|
||||
AppDomain compilerDomain = AppDomain.CreateDomain("CompilerDomain", null, setup);
|
||||
@@ -499,19 +502,33 @@ namespace System.Workflow.ComponentModel.Compiler
|
||||
parameters.GenerateInMemory = false;
|
||||
|
||||
if (string.IsNullOrEmpty(parameters.OutputAssembly))
|
||||
parameters.OutputAssembly = Path.GetTempFileName() + ".dll";
|
||||
{
|
||||
// We need to remember the filename generated by Path.GetTempFileName so we can clean it up.
|
||||
createdTempFileName = Path.GetTempFileName();
|
||||
parameters.OutputAssembly = createdTempFileName + ".dll";
|
||||
}
|
||||
else
|
||||
{
|
||||
int tries = 0;
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
DirectoryInfo info = Directory.CreateDirectory(Path.GetTempPath() + "\\" + Guid.NewGuid());
|
||||
tries++;
|
||||
createdDirectoryName = Path.GetTempPath() + "\\" + Guid.NewGuid();
|
||||
DirectoryInfo info = Directory.CreateDirectory(createdDirectoryName);
|
||||
parameters.OutputAssembly = info.FullName + "\\" + parameters.OutputAssembly;
|
||||
break;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// If we have tried 10 times without success, give up. Something must be wrong
|
||||
// with what gets returned by GetTempPath or we have exceeded max_path by appending
|
||||
// the GUID.
|
||||
if (tries >= 10)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -524,15 +541,6 @@ namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
results.CompiledAssembly = Assembly.Load(File.ReadAllBytes(results.PathToAssembly));
|
||||
results.PathToAssembly = null;
|
||||
|
||||
// Delete the file and directory.
|
||||
try
|
||||
{
|
||||
File.Delete(parameters.OutputAssembly);
|
||||
Directory.Delete(Path.GetDirectoryName(parameters.OutputAssembly), true);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
return results;
|
||||
@@ -555,8 +563,20 @@ namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
try
|
||||
{
|
||||
// There will always be an outputAssemblyName to delete.
|
||||
File.Delete(outputAssembly);
|
||||
Directory.Delete(Path.GetDirectoryName(outputAssembly), true);
|
||||
|
||||
// If we created a temp file name with Path.GetTempFileName, we need to delete it here.
|
||||
if (createdTempFileName != null)
|
||||
{
|
||||
File.Delete(createdTempFileName);
|
||||
}
|
||||
|
||||
// If we created a directory, delete it.
|
||||
if (createdDirectoryName != null)
|
||||
{
|
||||
Directory.Delete(createdDirectoryName, true);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
@@ -654,12 +674,13 @@ namespace System.Workflow.ComponentModel.Compiler
|
||||
|
||||
TempFileCollection intermediateTempFiles = null;
|
||||
string localAssemblyPath = string.Empty;
|
||||
string createdDirectoryName = null;
|
||||
|
||||
try
|
||||
{
|
||||
using (WorkflowCompilationContext.CreateScope(serviceContainer, parameters))
|
||||
{
|
||||
parameters.LocalAssembly = GenerateLocalAssembly(files, codeFiles, parameters, results, out intermediateTempFiles, out localAssemblyPath);
|
||||
parameters.LocalAssembly = GenerateLocalAssembly(files, codeFiles, parameters, results, out intermediateTempFiles, out localAssemblyPath, out createdDirectoryName);
|
||||
if (parameters.LocalAssembly != null)
|
||||
{
|
||||
// WinOE Bug 17591: we must set the local assembly here,
|
||||
@@ -685,10 +706,6 @@ namespace System.Workflow.ComponentModel.Compiler
|
||||
// Delate the temp files.
|
||||
if (intermediateTempFiles != null && parameters.TempFiles.KeepFiles == false)
|
||||
{
|
||||
string tempAssemblyDirectory = string.Empty;
|
||||
if (File.Exists(localAssemblyPath))
|
||||
tempAssemblyDirectory = Path.GetDirectoryName(localAssemblyPath);
|
||||
|
||||
foreach (string file in intermediateTempFiles)
|
||||
{
|
||||
try
|
||||
@@ -702,8 +719,12 @@ namespace System.Workflow.ComponentModel.Compiler
|
||||
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(tempAssemblyDirectory))
|
||||
Directory.Delete(tempAssemblyDirectory, true);
|
||||
// GenerateLocalAssembly may have created a directory, so let's try to delete it
|
||||
// We can't just delete Path.GetDirectoryName(localAssemblyPath) because it might be the Temp directory.
|
||||
if (createdDirectoryName != null)
|
||||
{
|
||||
Directory.Delete(createdDirectoryName, true);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -764,9 +785,10 @@ namespace System.Workflow.ComponentModel.Compiler
|
||||
return validationErrors;
|
||||
}
|
||||
|
||||
private Assembly GenerateLocalAssembly(string[] files, string[] codeFiles, WorkflowCompilerParameters parameters, WorkflowCompilerResults results, out TempFileCollection tempFiles2, out string localAssemblyPath)
|
||||
private Assembly GenerateLocalAssembly(string[] files, string[] codeFiles, WorkflowCompilerParameters parameters, WorkflowCompilerResults results, out TempFileCollection tempFiles2, out string localAssemblyPath, out string createdDirectoryName)
|
||||
{
|
||||
localAssemblyPath = string.Empty;
|
||||
createdDirectoryName = null;
|
||||
tempFiles2 = null;
|
||||
|
||||
// Generate code for the markup files.
|
||||
@@ -796,16 +818,38 @@ namespace System.Workflow.ComponentModel.Compiler
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(tempAssemblyDirectory))
|
||||
{
|
||||
break;
|
||||
}
|
||||
Directory.CreateDirectory(tempAssemblyDirectory);
|
||||
createdDirectoryName = tempAssemblyDirectory;
|
||||
break;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// If we have tried 10 times without success, give up. Something must be wrong
|
||||
// with what gets returned by TempFiles.BasePath
|
||||
if (postfix >= 10)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
tempAssemblyDirectory = clonedParams.TempFiles.BasePath + postfix++;
|
||||
}
|
||||
|
||||
}
|
||||
localAssemblyPath = clonedParams.OutputAssembly = tempAssemblyDirectory + "\\" + Path.GetFileName(clonedParams.OutputAssembly);
|
||||
clonedParams.TempFiles.AddFile(localAssemblyPath, true);
|
||||
|
||||
// Working around the fact that when the OutputAssembly is specified, the
|
||||
// codeDomProvider.CompileAssemblyFromFile call below does NOT add the pdb file
|
||||
// to the clonedParams.TempFiles collection. Instead, it looks as though it
|
||||
// does a clonedParams.TempFiles.BasePath.AddExtension("pdb"), which is a file
|
||||
// that doesn't actually get created.
|
||||
// We need to add the pdb file to the clonedParameters.TempFiles collection so that
|
||||
// it gets deleted, even in the case where we didn't end up creating the tempAssemblyDirectory above.
|
||||
string pdbFilename = Path.GetFileNameWithoutExtension(localAssemblyPath) + ".pdb";
|
||||
clonedParams.TempFiles.AddFile(Path.GetDirectoryName(localAssemblyPath) + "\\" + pdbFilename, true);
|
||||
}
|
||||
|
||||
// Explictily ignore warnings (in case the user set this property in the project options).
|
||||
|
@@ -10,7 +10,7 @@ namespace System.Workflow.ComponentModel
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Reflection;
|
||||
|
||||
//
|
||||
//TODO: remove this inheritence, when event binding service line UseMethod and FreeMethod methods are fixed.
|
||||
[DesignerSerializer(typeof(WorkflowMarkupSerializer), typeof(WorkflowMarkupSerializer))]
|
||||
[DesignerSerializer(typeof(DependencyObjectCodeDomSerializer), typeof(CodeDomSerializer))]
|
||||
[TypeConverter(typeof(ConditionTypeConverter))]
|
||||
|
@@ -10,7 +10,7 @@ using System;
|
||||
|
||||
/*********************************************************************
|
||||
* NOTE: A copy of this file exists at: WF\Activities\Common
|
||||
* The two files must be kept in [....]. Any change made here must also
|
||||
* The two files must be kept in sync. Any change made here must also
|
||||
* be made to WF\Activities\Common\AssemblyRef.cs
|
||||
*********************************************************************/
|
||||
|
||||
|
Reference in New Issue
Block a user