|
89 | 89 |
|
90 | 90 | <!-- Add Client SDK Tools -->
|
91 | 91 | <ItemGroup>
|
92 |
| - <PackageReference Condition="'$(IsClientLibrary)' == 'true'" Include="Microsoft.Azure.AutoRest.CSharp" PrivateAssets="All" /> |
| 92 | + <PackageReference Condition="'$(IncludeAutorestDependency)' == 'true'" Include="Microsoft.Azure.AutoRest.CSharp" PrivateAssets="All" /> |
93 | 93 |
|
94 | 94 | <PackageReference Condition="'$(GenerateAPIListing)' == 'true'" Include="Microsoft.DotNet.GenAPI" PrivateAssets="All" />
|
95 | 95 |
|
|
435 | 435 | <ProjectsToInclude Include="$(_ProjectName)" />
|
436 | 436 | </ItemGroup>
|
437 | 437 | </Target>
|
| 438 | + |
| 439 | + <PropertyGroup> |
| 440 | + <TypeSpecInput Condition="Exists('$(MSBuildProjectDirectory)/../tsp-location.yaml') and $(MSBuildProjectDirectory.EndsWith('src'))">$(MSBuildProjectDirectory)/../tsp-location.yaml</TypeSpecInput> |
| 441 | + <_TypeSpecProjectGenerateCommand>npx --no-install --package=@azure-tools/typespec-client-generator-cli --yes tsp-client generate --no-prompt --output-dir $(MSBuildProjectDirectory)/../</_TypeSpecProjectGenerateCommand> |
| 442 | + <_TypeSpecProjectSyncAndGenerateCommand>npx --no-install --package=@azure-tools/typespec-client-generator-cli --yes tsp-client update --no-prompt --output-dir $(MSBuildProjectDirectory)/../</_TypeSpecProjectSyncAndGenerateCommand> |
| 443 | + <_SaveInputs Condition="'$(SaveInputs)' == 'true'">--save-inputs</_SaveInputs> |
| 444 | + <!-- Here we append the generate-test-project configuration to TypespecAdditionalOptions if it is specified --> |
| 445 | + <TypespecAdditionalOptions Condition="'$(GenerateTestProject)' != '' AND '$(TypespecAdditionalOptions)' != ''">$(TypespecAdditionalOptions)%3Bgenerate-test-project=true</TypespecAdditionalOptions> |
| 446 | + <TypespecAdditionalOptions Condition="'$(GenerateTestProject)' != '' AND '$(TypespecAdditionalOptions)' == ''">generate-test-project=true</TypespecAdditionalOptions> |
| 447 | + <_TypespecAdditionalOptions Condition="'$(TypespecAdditionalOptions)' != ''">--emitter-options "$(TypespecAdditionalOptions)"</_TypespecAdditionalOptions> |
| 448 | + <_LocalSpecRepo Condition="'$(LocalSpecRepo)' != ''">--local-spec-repo $(LocalSpecRepo)</_LocalSpecRepo> |
| 449 | + </PropertyGroup> |
| 450 | + |
| 451 | + <!-- For projects using the new TypeSpec generator, we don't include the Autorest dependency which pulls in the GenerateCode target. |
| 452 | + So we need to add it here. --> |
| 453 | + <Target Name="GenerateCode" Condition="'$(IncludeAutorestDependency)' != 'true' AND '$(TypeSpecInput)' != ''"> |
| 454 | + <Error Text="You used skipped sync but didn't have the TempTypeSpecFiles in your project directory. Please run 'dotnet build /t:GenerateCode /p:SaveInputs=true' without SkipSync first at least once" Condition="'$(SkipSync)' == 'true' AND !Exists('$(MSBuildProjectDirectory)/../TempTypeSpecFiles')" /> |
| 455 | + <Exec Command="npm install --prefix $(MSBuildProjectDirectory)/../ @azure-tools/typespec-client-generator-cli --no-save" /> |
| 456 | + <Exec Condition="'$(SkipSync)' == 'true'" Command="$(_TypeSpecProjectGenerateCommand) $(_SaveInputs) $(_TypespecAdditionalOptions) $(_Debug)"/> |
| 457 | + <Exec Condition="'$(SkipSync)' != 'true'" Command="$(_TypeSpecProjectSyncAndGenerateCommand) $(_SaveInputs) $(_LocalSpecRepo) $(_TypespecAdditionalOptions) $(_Debug)"/> |
| 458 | + </Target> |
438 | 459 |
|
439 | 460 | <Import Project="$(CentralPackageVersionPackagePath)\Sdk.targets" />
|
440 | 461 | </Project>
|
0 commit comments