38 lines
2.6 KiB
XML
38 lines
2.6 KiB
XML
<Project>
|
|
<PropertyGroup>
|
|
<!-- Set default values for proto generation -->
|
|
<GenerateProtoFile Condition="'$(GenerateProtoFile)' == ''">true</GenerateProtoFile>
|
|
<ProtoOutputDirectory Condition="'$(ProtoOutputDirectory)' == ''">$(MSBuildProjectDirectory)\Protos</ProtoOutputDirectory>
|
|
<GeneratedProtoFileName Condition="'$(GeneratedProtoFileName)' == ''">cqrs_services.proto</GeneratedProtoFileName>
|
|
</PropertyGroup>
|
|
|
|
<!-- Determine the assembly path (different for NuGet package vs project reference) -->
|
|
<PropertyGroup>
|
|
<_GeneratorsAssemblyPath Condition="Exists('$(MSBuildThisFileDirectory)\..\analyzers\dotnet\cs\Svrnty.CQRS.Grpc.Generators.dll')">$(MSBuildThisFileDirectory)\..\analyzers\dotnet\cs\Svrnty.CQRS.Grpc.Generators.dll</_GeneratorsAssemblyPath>
|
|
<_GeneratorsAssemblyPath Condition="'$(_GeneratorsAssemblyPath)' == '' AND Exists('$(MSBuildThisFileDirectory)\..\bin\Debug\netstandard2.0\Svrnty.CQRS.Grpc.Generators.dll')">$(MSBuildThisFileDirectory)\..\bin\Debug\netstandard2.0\Svrnty.CQRS.Grpc.Generators.dll</_GeneratorsAssemblyPath>
|
|
<_GeneratorsAssemblyPath Condition="'$(_GeneratorsAssemblyPath)' == '' AND Exists('$(MSBuildThisFileDirectory)\..\bin\Release\netstandard2.0\Svrnty.CQRS.Grpc.Generators.dll')">$(MSBuildThisFileDirectory)\..\bin\Release\netstandard2.0\Svrnty.CQRS.Grpc.Generators.dll</_GeneratorsAssemblyPath>
|
|
</PropertyGroup>
|
|
|
|
<!-- Load the WriteProtoFileTask from the generator assembly -->
|
|
<UsingTask TaskName="Svrnty.CQRS.Grpc.Generators.WriteProtoFileTask"
|
|
AssemblyFile="$(_GeneratorsAssemblyPath)"
|
|
Condition="'$(_GeneratorsAssemblyPath)' != ''" />
|
|
|
|
<!-- This target ensures the Protos directory exists before the generator runs -->
|
|
<Target Name="EnsureProtosDirectory" BeforeTargets="CoreCompile">
|
|
<MakeDir Directories="$(ProtoOutputDirectory)" Condition="!Exists('$(ProtoOutputDirectory)')" />
|
|
</Target>
|
|
|
|
<!-- Extract the proto file from the source generator output BEFORE Grpc.Tools processes protos -->
|
|
<!-- Runs before CoreCompile, after source generators have been executed -->
|
|
<Target Name="SvrntyExtractProtoFile" BeforeTargets="CoreCompile" AfterTargets="ResolveProjectReferences" DependsOnTargets="EnsureProtosDirectory" Condition="'$(GenerateProtoFile)' == 'true'">
|
|
<Message Text="Svrnty.CQRS.Grpc: Extracting auto-generated proto file to $(ProtoOutputDirectory)\$(GeneratedProtoFileName)" Importance="high" />
|
|
|
|
<WriteProtoFileTask
|
|
ProjectDirectory="$(MSBuildProjectDirectory)"
|
|
IntermediateOutputPath="$(IntermediateOutputPath)"
|
|
OutputDirectory="$(ProtoOutputDirectory)"
|
|
ProtoFileName="$(GeneratedProtoFileName)" />
|
|
</Target>
|
|
</Project>
|