|
|
|
@ -98,12 +98,24 @@ namespace ICSharpCode.SharpDevelop.Project
@@ -98,12 +98,24 @@ namespace ICSharpCode.SharpDevelop.Project
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public string GetOutputFileName(FileProjectItem baseItem, string additionalExtension) |
|
|
|
|
{ |
|
|
|
|
return GetOutputFileName(baseItem, additionalExtension, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public string GetOutputFileName(FileProjectItem baseItem, string additionalExtension, bool isPrimaryOutput) |
|
|
|
|
{ |
|
|
|
|
if (baseItem == null) |
|
|
|
|
throw new ArgumentNullException("baseItem"); |
|
|
|
|
if (baseItem.Project != project) |
|
|
|
|
throw new ArgumentException("baseItem is not from project this CustomToolContext belongs to"); |
|
|
|
|
|
|
|
|
|
if (isPrimaryOutput) { |
|
|
|
|
string lastGenOutput = baseItem.GetEvaluatedMetadata("LastGenOutput"); |
|
|
|
|
if (!string.IsNullOrEmpty(lastGenOutput)) { |
|
|
|
|
return Path.Combine(Path.GetDirectoryName(baseItem.FileName), lastGenOutput); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
string newExtension = null; |
|
|
|
|
if (project.LanguageProperties.CodeDomProvider != null) { |
|
|
|
|
newExtension = project.LanguageProperties.CodeDomProvider.FileExtension; |
|
|
|
@ -120,22 +132,55 @@ namespace ICSharpCode.SharpDevelop.Project
@@ -120,22 +132,55 @@ namespace ICSharpCode.SharpDevelop.Project
|
|
|
|
|
newExtension = "." + newExtension; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Path.ChangeExtension(baseItem.FileName, additionalExtension + newExtension); |
|
|
|
|
string newFileName = Path.ChangeExtension(baseItem.FileName, additionalExtension + newExtension); |
|
|
|
|
int retryIndex = 0; |
|
|
|
|
while (true) { |
|
|
|
|
FileProjectItem item = project.FindFile(newFileName); |
|
|
|
|
// If the file does not exist in the project, we can use that name.
|
|
|
|
|
if (item == null) |
|
|
|
|
return newFileName; |
|
|
|
|
// If the file already exists in the project, use it only if it belongs to our base item
|
|
|
|
|
if (string.Equals(item.DependentUpon, Path.GetFileName(baseItem.FileName), StringComparison.OrdinalIgnoreCase)) |
|
|
|
|
return newFileName; |
|
|
|
|
// Otherwise, find another free file name
|
|
|
|
|
retryIndex++; |
|
|
|
|
newFileName = Path.ChangeExtension(baseItem.FileName, additionalExtension + retryIndex + newExtension); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public FileProjectItem EnsureOutputFileIsInProject(FileProjectItem baseItem, string outputFileName) |
|
|
|
|
{ |
|
|
|
|
return EnsureOutputFileIsInProject(baseItem, outputFileName, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public FileProjectItem EnsureOutputFileIsInProject(FileProjectItem baseItem, string outputFileName, bool isPrimaryOutput) |
|
|
|
|
{ |
|
|
|
|
if (baseItem == null) |
|
|
|
|
throw new ArgumentNullException("baseItem"); |
|
|
|
|
if (baseItem.Project != project) |
|
|
|
|
throw new ArgumentException("baseItem is not from project this CustomToolContext belongs to"); |
|
|
|
|
|
|
|
|
|
WorkbenchSingleton.AssertMainThread(); |
|
|
|
|
bool saveProject = false; |
|
|
|
|
if (isPrimaryOutput) { |
|
|
|
|
if (baseItem.GetEvaluatedMetadata("LastGenOutput") != Path.GetFileName(outputFileName)) { |
|
|
|
|
saveProject = true; |
|
|
|
|
baseItem.SetEvaluatedMetadata("LastGenOutput", Path.GetFileName(outputFileName)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
FileProjectItem outputItem = project.FindFile(outputFileName); |
|
|
|
|
if (outputItem == null) { |
|
|
|
|
outputItem = new FileProjectItem(project, ItemType.Compile); |
|
|
|
|
outputItem.FileName = outputFileName; |
|
|
|
|
outputItem.DependentUpon = Path.GetFileName(baseItem.FileName); |
|
|
|
|
outputItem.SetEvaluatedMetadata("AutoGen", "True"); |
|
|
|
|
ProjectService.AddProjectItem(project, outputItem); |
|
|
|
|
FileService.FireFileCreated(outputFileName, false); |
|
|
|
|
project.Save(); |
|
|
|
|
saveProject = true; |
|
|
|
|
ProjectBrowserPad.RefreshViewAsync(); |
|
|
|
|
} |
|
|
|
|
if (saveProject) |
|
|
|
|
project.Save(); |
|
|
|
|
return outputItem; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -463,7 +508,7 @@ namespace ICSharpCode.SharpDevelop.Project
@@ -463,7 +508,7 @@ namespace ICSharpCode.SharpDevelop.Project
|
|
|
|
|
activeToolRun = null; |
|
|
|
|
if(toolRuns.Count > 0) { |
|
|
|
|
CustomToolRun nextRun = toolRuns.Dequeue(); |
|
|
|
|
if(nextRun != null) { |
|
|
|
|
if(nextRun != null) { |
|
|
|
|
RunCustomTool(nextRun); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|