Skip to content

Instantly share code, notes, and snippets.

@usausa
Last active August 7, 2019 01:01
Show Gist options
  • Select an option

  • Save usausa/3f512fe04b910d6be7deef479db595e3 to your computer and use it in GitHub Desktop.

Select an option

Save usausa/3f512fe04b910d6be7deef479db595e3 to your computer and use it in GitHub Desktop.
<?xml version="1.0"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<GenerateFileName>$(AssemblyName).sha256</GenerateFileName>
</PropertyGroup>
<!-- For build output -->
<Target Name="GenerateGetCopyToOutputDirectoryItems"
BeforeTargets="GetCopyToOutputDirectoryItems">
<Message Text="**** GenerateGetCopyToOutputDirectoryItems ****"/>
<PropertyGroup>
<GenerateFullPath>$([System.IO.Path]::GetFullPath('$(OutputPath)$(GenerateFileName)'))</GenerateFullPath>
</PropertyGroup>
<ItemGroup>
<FileWrites Include="$(OutputPath)$(GenerateFileName)"/>
<AllItemsFullPathWithTargetPath Include="$(GenerateFullPath)">
<TargetPath>$(GenerateFileName)</TargetPath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</AllItemsFullPathWithTargetPath>
</ItemGroup>
</Target>
<!-- For publish output -->
<Target Name="GenerateGetCopyToPublishDirectoryItems"
BeforeTargets="GetCopyToPublishDirectoryItems"
Returns="@(AllPublishItemsFullPathWithTargetPath)">
<Message Text="**** GenerateGetCopyToPublishDirectoryItems ****"/>
<PropertyGroup>
<GenerateFullPath>$([System.IO.Path]::GetFullPath('$(OutputPath)$(GenerateFileName)'))</GenerateFullPath>
</PropertyGroup>
<Message Text="$(GenerateFullPath)"/>
<ItemGroup>
<AllPublishItemsFullPathWithTargetPath Include="$(GenerateFullPath)">
<TargetPath>$(GenerateFileName)</TargetPath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</AllPublishItemsFullPathWithTargetPath>
</ItemGroup>
</Target>
<!-- Generate additional item -->
<Target Name="GenerateAdditionalItems"
AfterTargets="Build"
Inputs="$(OutputPath)$(TargetFileName)"
Outputs="$(OutputPath)$(GenerateFileName)">
<Message Text="**** GenerateAdditionalItems ****"/>
<GetFileHash Files="$(OutputPath)$(TargetFileName)">
<Output TaskParameter="Items" ItemName="Hash" />
</GetFileHash>
<WriteLinesToFile File="$(OutputPath)$(GenerateFileName)" Lines="@(Hash->'%(FileHash)')" Overwrite="true"/>
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment