Skip to content

Commit

Permalink
Added method to skip cleaning of output assemblies to ExtensionsMetad…
Browse files Browse the repository at this point in the history
…ataGenerator.
  • Loading branch information
gzuber committed Nov 9, 2020
1 parent ecaafa2 commit 8471a52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@ public class RemoveRuntimeDependencies : Task
[Required]
public string OutputPath { get; set; }

[Required]
public ITaskItem[] IgnoreFiles { get; set; }

public override bool Execute()
{
HashSet<string> ignoreFilesSet = new HashSet<string>();
foreach (ITaskItem item in IgnoreFiles)
{
ignoreFilesSet.Add(item.ItemSpec);
}

Assembly assembly = typeof(RemoveRuntimeDependencies).Assembly;
using (Stream resource = assembly.GetManifestResourceStream(assembly.GetName().Name + ".runtimeassemblies.txt"))
using (var reader = new StreamReader(resource))
Expand All @@ -32,7 +41,7 @@ public override bool Execute()
{
string fileName = Path.Combine(OutputPath, assemblyName);

if (File.Exists(fileName))
if (File.Exists(fileName) && !ignoreFilesSet.Contains(assemblyName))
{
File.Delete(fileName);
}
Expand All @@ -44,4 +53,4 @@ public override bool Execute()
return true;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
AssemblyFile="$(_FunctionsExtensionsTaskAssemblyFullPath)"/>

<Target Name="_FunctionsBuildCleanOutput" AfterTargets="_GenerateFunctionsExtensionsMetadataPostBuild" Condition="$(_FunctionsSkipCleanOutput) != 'true'" >
<RemoveRuntimeDependencies OutputPath="$(TargetDir)bin"/>
<RemoveRuntimeDependencies OutputPath="$(TargetDir)bin" IgnoreFiles="@(FunctionsPreservedDependencies)"/>
</Target>

<Target Name="_FunctionsPublishCleanOutput" AfterTargets="_GenerateFunctionsExtensionsMetadataPostPublish" Condition="$(_FunctionsSkipCleanOutput) != 'true'" >
<RemoveRuntimeDependencies OutputPath="$(PublishDir)bin"/>
<RemoveRuntimeDependencies OutputPath="$(PublishDir)bin" IgnoreFiles="@(FunctionsPreservedDependencies)"/>
</Target>

<UsingTask TaskName="GenerateFunctionsExtensionsMetadata"
Expand Down

0 comments on commit 8471a52

Please sign in to comment.