zcsizmadia commented on code in PR #1966:
URL: https://github.com/apache/avro/pull/1966#discussion_r1022130850


##########
lang/csharp/README.md:
##########
@@ -39,6 +39,36 @@ Install-Package Apache.Avro
 2. By updating the versions in our libraries, we require users of the library 
to update to a version equal to or greater than the version we reference. For 
example, if a user were to reference an older version of Newtonsoft.Json, they 
would be forced to update to a newer version before they could use a new 
version of the Avro library.
 In short, we should only update the version of the dependencies in our 
libraries if we absolutely must for functionality that we require. We leave it 
up to the users of the library as to whether or not they want the latest and 
greatest of a particularly dependency. We're only going to require the bare 
minimum.
 
+## MSBuild Avro Generator Task
+
+MSBuild task `AvroGenTask` can be used to compile avro schema or protocol 
files from `.csproj`, without explicitly calling `avrogen` tool binary.
+
+Example:
+
+```
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>net6.0</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <SchemaFiles Include="schemas/**/*.avsc" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Apache.Avro" Version="1.11.2 />
+    <PackageReference Include="Apache.Avro.MSBuild" Version="1.11.2" 
PrivateAssets="All" />
+  </ItemGroup>
+
+  <Target Name="AvroGenerate" BeforeTargets="CoreCompile">
+    <AvroGenTask SchemaFiles="@(SchemaFiles)" OutDir="generated" />

Review Comment:
   This is the same way avrogen would work. The cs generation will happen every 
time  this task is triggered. To implement dependencies, basic mechanism can be 
implemented, using Inputs and Outputs props of Target.
   
   SInce the schema -> cs mapping is not 1 to 1, implementing the dependencies 
inside the codegen library is not trivial (as it is currently implemented). 
This PR simply let the user use an MSBuild task tinstead of calling avrogen. 
Avrogen as a tool has a limitation that it relies on a specific SDK version. 
E.g until the net7 version of avrogen is not released, avrogen cannot be used 
in a net7 only NET SDK container.
   
   Using MSBuild tasks are solving that issue, since the MSBuild task package 
is targeting netstandard2.0.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to