Skip to content

Instantly share code, notes, and snippets.

@trapezoid
Last active August 17, 2023 10:22
Show Gist options
  • Save trapezoid/90d5c09c51e4caa24a010572a04061eb to your computer and use it in GitHub Desktop.
Save trapezoid/90d5c09c51e4caa24a010572a04061eb to your computer and use it in GitHub Desktop.
Grpc.Toolsでのコード生成をOutputDir指定で永続的に吐き出したい場合に、dotnet cleanで生成されたコードが削除されるのを防ぐ
<Project Sdk="Microsoft.NET.Sdk">
<!-- clean時の削除タスクの実行前に生成ファイル一覧をクリアして、削除後に元に戻す -->
<Target Name="_Protobuf_CoreClean_Stash" BeforeTargets="_Protobuf_CoreClean">
<ItemGroup>
<Protobuf_ExpectedOutputsStashed Include="@(Protobuf_ExpectedOutputs)" />
<Protobuf_ExpectedOutputs Remove="@(Protobuf_ExpectedOutputsStashed)" />
</ItemGroup>
</Target>
<Target Name="_Protobuf_CoreClean_Restore" AfterTargets="_Protobuf_CoreClean">
<ItemGroup>
<Protobuf_ExpectedOutputs Include="@(Protobuf_ExpectedOutputsStashed)" />
</ItemGroup>
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment