diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 7a9d800bdada..659492badf32 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -25,6 +25,12 @@ "commands": [ "generate-sbom" ] - } + }, + "Google.Api.Generator": { + "version": "1.5.0", + "commands": [ + "google-gapic-generator" + ] + } } } diff --git a/toolversions.sh b/toolversions.sh index a1aa68639f2c..1989808b97e0 100755 --- a/toolversions.sh +++ b/toolversions.sh @@ -13,12 +13,6 @@ declare -r DOTCOVER_VERSION=2019.3.4 declare -r REPORTGENERATOR_VERSION=2.4.5.0 declare -r PROTOC_VERSION=3.25.2 declare -r GRPC_VERSION=2.60.0 -if [[ $GAPIC_GENERATOR_VERSION == "" ]] -then - declare -r GAPIC_GENERATOR_VERSION=v1.4.32 -else - echo "Using GAPIC generator override: ${GAPIC_GENERATOR_VERSION}" -fi # Tools that only run under Windows (at the moment) declare -r DOTCOVER=$TOOL_PACKAGES/JetBrains.dotCover.CommandLineTools.$DOTCOVER_VERSION/tools/dotCover.exe @@ -102,32 +96,20 @@ install_microgenerator() { # If the CSHARP_GENERATOR_DIR env variable is set # we use that as the generator root dir. - if [[ "$CSHARP_GENERATOR_DIR" != "" ]] - then - declare -r GENERATOR_ROOT=$CSHARP_GENERATOR_DIR - else - declare -r GENERATOR_ROOT=$REPO_ROOT/gapic-generator-csharp - fi - - export GAPIC_PLUGIN=$GENERATOR_ROOT/Google.Api.Generator/bin/Release/net6.0/$RUNTIME/publish/Google.Api.Generator$EXTENSION - if [[ "$CSHARP_GENERATOR_DIR" != "" ]] then echo "Skipping microgenerator fetch: an existing directory for the generator has been specified" - elif [ -d $GENERATOR_ROOT ] - then - git -C $GENERATOR_ROOT fetch -q --tags - git -C $GENERATOR_ROOT checkout -q $GAPIC_GENERATOR_VERSION + (cd $CSHARP_GENERATOR_DIR; \ + dotnet restore -v quiet; \ + dotnet publish -v quiet -nologo -clp:NoSummary -c Release --self-contained --runtime=$RUNTIME Google.Api.Generator) + export GAPIC_PLUGIN=$CSHARP_GENERATOR_DIR/Google.Api.Generator/bin/Release/net6.0/$RUNTIME/publish/Google.Api.Generator$EXTENSION else - git clone https://github.com/googleapis/gapic-generator-csharp $GENERATOR_ROOT -q - git -C $GENERATOR_ROOT checkout -q $GAPIC_GENERATOR_VERSION + # We don't just use "dotnet tool restore", as we need it installed in a specific + # path in order to access the executable directly (as it's a protoc plugin). + rm -rf gapic-generator + dotnet tool install Google.Api.Generator --tool-path gapic-generator > /dev/null + export GAPIC_PLUGIN=$REPO_ROOT/gapic-generator/google-gapic-generator$EXTENSION fi - - # The dotnet restore step isn't generally required when cloning from elsewhere, - # but helps when running a local generator. (It does no harm even when not required.) - (cd $GENERATOR_ROOT; \ - dotnet restore -v quiet; \ - dotnet publish -v quiet -nologo -clp:NoSummary -c Release --self-contained --runtime=$RUNTIME Google.Api.Generator) } install_grpc() {