Add props and targets file for MSBuild

This commit is contained in:
TSR Berry 2022-12-15 16:49:21 +01:00
parent 939e700542
commit 98600536a2
No known key found for this signature in database
GPG Key ID: 52353C0A4CCA15E2
2 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- The folder where the custom task will be present. It points to inside the nuget package. -->
<_TaskFolder>$(MSBuildThisFileDirectory)..\tasks\netstandard2.0</_TaskFolder>
<!-- Reference to the assembly which contains the MSBuild Task -->
<CustomTasksAssembly>$(_TaskFolder)\$(MSBuildThisFileName).dll</CustomTasksAssembly>
</PropertyGroup>
<!-- Register our custom tasks -->
<UsingTask TaskName="$(MSBuildThisFileName).GenerateArrays" AssemblyFile="$(CustomTasksAssembly)"/>
</Project>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Task: GenerateArrays -->
<!-- Defining all sources files of the current project for the input parameter -->
<ItemGroup>
<ArrayInputFiles Condition="'$(ArrayInputFiles)' == ''" Include="$(MSBuildProjectDirectory)\**\*.cs" />
</ItemGroup>
<!--A target that generates code, which is executed before the compilation-->
<!-- TODO: Make "Outputs" more generic -->
<Target Name="BeforeCompile" Inputs="@(ArrayInputFiles)" Outputs="$(ArrayOutputPath)\Arrays.g.cs">
<!--Calling our custom task -->
<GenerateArrays ArrayNamespace="$(ArrayNamespace)" InputFiles="@(ArrayInputFiles)" OutputPath="$(ArrayOutputPath)">
<Output TaskParameter="OutputFiles" PropertyName="ArrayOutputFiles" />
</GenerateArrays>
<!--Our generated files are included to be compiled-->
<ItemGroup>
<Compile Remove="@(ArrayOutputFiles)" />
<Compile Include="@(ArrayOutputFiles)" />
</ItemGroup>
</Target>
<!--The generated files are deleted after a general clean. It will force the regeneration on rebuild -->
<Target Name="AfterClean">
<Delete Files="$(ArrayOutputPath)\*.g.cs" />
</Target>
</Project>