Clean up build output folder for wrapper.
parent
b87920e5aa
commit
cff22512f7
|
@ -84,6 +84,43 @@
|
||||||
</Target>
|
</Target>
|
||||||
<Import Project="$(SolutionDir)packages\Fody.1.26.4\build\Fody.targets" Condition="Exists('$(SolutionDir)packages\Fody.1.26.4\build\Fody.targets')" />
|
<Import Project="$(SolutionDir)packages\Fody.1.26.4\build\Fody.targets" Condition="Exists('$(SolutionDir)packages\Fody.1.26.4\build\Fody.targets')" />
|
||||||
<Import Project="$(SolutionDir)packages\GitVersionTask.2.0.0\Build\GitVersionTask.targets" Condition="Exists('$(SolutionDir)packages\GitVersionTask.2.0.0\Build\GitVersionTask.targets')" />
|
<Import Project="$(SolutionDir)packages\GitVersionTask.2.0.0\Build\GitVersionTask.targets" Condition="Exists('$(SolutionDir)packages\GitVersionTask.2.0.0\Build\GitVersionTask.targets')" />
|
||||||
|
<UsingTask TaskName="CosturaCleanup" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" TaskFactory="CodeTaskFactory">
|
||||||
|
<ParameterGroup>
|
||||||
|
<Config Output="false" Required="true" ParameterType="Microsoft.Build.Framework.ITaskItem" />
|
||||||
|
<Files Output="false" Required="true" ParameterType="Microsoft.Build.Framework.ITaskItem[]" />
|
||||||
|
</ParameterGroup>
|
||||||
|
<Task Evaluate="true">
|
||||||
|
<Reference xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Include="System.Xml" />
|
||||||
|
<Reference xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Include="System.Xml.Linq" />
|
||||||
|
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System" />
|
||||||
|
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System.IO" />
|
||||||
|
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System.Xml.Linq" />
|
||||||
|
<Code xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Type="Fragment" Language="cs">
|
||||||
|
<![CDATA[
|
||||||
|
var config = XElement.Load(Config.ItemSpec).Elements("Costura").FirstOrDefault();
|
||||||
|
|
||||||
|
if (config == null) return true;
|
||||||
|
|
||||||
|
var excludedAssemblies = new List<string>();
|
||||||
|
var attribute = config.Attribute("ExcludeAssemblies");
|
||||||
|
if (attribute != null)
|
||||||
|
foreach (var item in attribute.Value.Split('|').Select(x => x.Trim()).Where(x => x != string.Empty))
|
||||||
|
excludedAssemblies.Add(item);
|
||||||
|
var element = config.Element("ExcludeAssemblies");
|
||||||
|
if (element != null)
|
||||||
|
foreach (var item in element.Value.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).Where(x => x != string.Empty))
|
||||||
|
excludedAssemblies.Add(item);
|
||||||
|
|
||||||
|
var filesToCleanup = Files.Select(f => f.ItemSpec).Where(f => !excludedAssemblies.Contains(Path.GetFileNameWithoutExtension(f), StringComparer.InvariantCultureIgnoreCase));
|
||||||
|
|
||||||
|
foreach (var item in filesToCleanup)
|
||||||
|
File.Delete(item);
|
||||||
|
]]>
|
||||||
|
</Code></Task>
|
||||||
|
</UsingTask>
|
||||||
|
<Target Name="CleanReferenceCopyLocalPaths" AfterTargets="AfterBuild;NonWinFodyTarget">
|
||||||
|
<CosturaCleanup Config="FodyWeavers.xml" Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
|
||||||
|
</Target>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
|
|
Loading…
Reference in New Issue