File tree Expand file tree Collapse file tree 2 files changed +24
-8
lines changed
src/Examples/OpenApiKiotaClientExample Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -226,16 +226,24 @@ The available command-line switches for Kiota are described [here](https://learn
226
226
227
227
At the time of writing, Kiota provides [ no official integration] ( https://github.com/microsoft/kiota/issues/3005 ) with MSBuild.
228
228
Our [ example project] ( https://github.com/json-api-dotnet/JsonApiDotNetCore/tree/openapi/src/Examples/OpenApiKiotaClientExample ) takes a stab at it,
229
- although it has glitches . If you're an MSBuild expert, please help out!
229
+ which seems to work . If you're an MSBuild expert, please help out!
230
230
231
231
``` xml
232
- <Target Name =" KiotaRunTool" BeforeTargets =" BeforeCompile;CoreCompile" Condition =" $(DesignTimeBuild) != true And $(BuildingProject) == true" >
232
+ <Target Name =" RemoveKiotaGeneratedCode" BeforeTargets =" BeforeCompile;CoreCompile" Condition =" $(DesignTimeBuild) != true And $(BuildingProject) == true" >
233
+ <ItemGroup >
234
+ <Compile Remove =" **\GeneratedCode\**\*.cs" />
235
+ </ItemGroup >
236
+ </Target >
237
+
238
+ <Target Name =" KiotaRunTool" BeforeTargets =" BeforeCompile;CoreCompile" AfterTargets =" RemoveKiotaGeneratedCode"
239
+ Condition =" $(DesignTimeBuild) != true And $(BuildingProject) == true" >
233
240
<Exec
234
- Command =" dotnet kiota generate --language CSharp --class-name ExampleApiClient --namespace-name OpenApiKiotaClientExample.GeneratedCode --output ./GeneratedCode --backing-store --exclude-backward-compatible --clean-output --clear-cache --openapi ..\JsonApiDotNetCoreExample\GeneratedSwagger\JsonApiDotNetCoreExample.json" />
241
+ Command =" dotnet kiota generate --language CSharp --class-name ExampleApiClient --namespace-name OpenApiKiotaClientExample.GeneratedCode --output ./GeneratedCode --backing-store --exclude-backward-compatible --clean-output --clear-cache --log-level Error --openapi ../JsonApiDotNetCoreExample/GeneratedSwagger/JsonApiDotNetCoreExample.json" />
242
+ </Target >
235
243
244
+ <Target Name =" IncludeKiotaGeneratedCode" BeforeTargets =" BeforeCompile;CoreCompile" AfterTargets =" KiotaRunTool"
245
+ Condition =" $(DesignTimeBuild) != true And $(BuildingProject) == true" >
236
246
<ItemGroup >
237
- <!-- This isn't entirely reliable: may require a second build after the source swagger.json has changed, to get rid of compile errors. -->
238
- <Compile Remove =" **\GeneratedCode\**\*.cs" />
239
247
<Compile Include =" **\GeneratedCode\**\*.cs" />
240
248
</ItemGroup >
241
249
</Target >
Original file line number Diff line number Diff line change 20
20
<PackageReference Include =" Microsoft.Kiota.Serialization.Text" Version =" $(KiotaVersion)" />
21
21
</ItemGroup >
22
22
23
- <Target Name =" KiotaRunTool" BeforeTargets =" BeforeCompile;CoreCompile" Condition =" $(DesignTimeBuild) != true And $(BuildingProject) == true" >
23
+ <Target Name =" RemoveKiotaGeneratedCode" BeforeTargets =" BeforeCompile;CoreCompile" Condition =" $(DesignTimeBuild) != true And $(BuildingProject) == true" >
24
+ <ItemGroup >
25
+ <Compile Remove =" **\GeneratedCode\**\*.cs" />
26
+ </ItemGroup >
27
+ </Target >
28
+
29
+ <Target Name =" KiotaRunTool" BeforeTargets =" BeforeCompile;CoreCompile" AfterTargets =" RemoveKiotaGeneratedCode"
30
+ Condition =" $(DesignTimeBuild) != true And $(BuildingProject) == true" >
24
31
<!--
25
32
Created from sources:
26
33
- https://github.com/microsoft/kiota/issues/3005#issuecomment-1657806848
30
37
-->
31
38
<Exec
32
39
Command =" dotnet kiota generate --language CSharp --class-name ExampleApiClient --namespace-name OpenApiKiotaClientExample.GeneratedCode --output ./GeneratedCode --backing-store --exclude-backward-compatible --clean-output --clear-cache --log-level Error --openapi ../JsonApiDotNetCoreExample/GeneratedSwagger/JsonApiDotNetCoreExample.json" />
40
+ </Target >
33
41
42
+ <Target Name =" IncludeKiotaGeneratedCode" BeforeTargets =" BeforeCompile;CoreCompile" AfterTargets =" KiotaRunTool"
43
+ Condition =" $(DesignTimeBuild) != true And $(BuildingProject) == true" >
34
44
<ItemGroup >
35
- <!-- This isn't entirely reliable: may require a second build after the source swagger.json has changed, to get rid of compile errors. -->
36
- <Compile Remove =" **\GeneratedCode\**\*.cs" />
37
45
<Compile Include =" **\GeneratedCode\**\*.cs" />
38
46
</ItemGroup >
39
47
</Target >
You can’t perform that action at this time.
0 commit comments