Skip to content

play-services-basement/merge.targets - ProcessGoogleServicesJson target is incorrectly skipped even when Input (GoogleServicesJson) changes #1282

@Xopabyteh

Description

@Xopabyteh

Android framework version

net9.0-android

Affected platform version

.NET 9.0.301

Description

We have multiple google-services.json files, per environment.
In our build pipeline, we select the appropriate file like so:

<!-- Some variable that changes based on environment -->
<EntitlementsPostifx Condition="'$(ApplicationEnvironmentName)' != ''">$(ApplicationEnvironmentName)</EntitlementsPostifx>
<GoogleServicesPostfix>$(EntitlementsPostifx)</GoogleServicesPostfix>

<!-- Parameter that selects google sevrices json based on the environment -->
<GoogleServicesJson Condition="$(TargetFramework.Contains('-android'))" Include="Platforms\Android\google-services-$(GoogleServicesPostfix).json" />

We first build the entire solution (without providing the environment name), then we build the use dotnet publish on the android project (MAUI) itself. But in the end an incorrect GoogleServicesJson is used - it uses the old one from when building the entire solution, because the target ProcessGoogleServicesJson is incorrectly skipped.

Steps to Reproduce

  1. New android app
  2. Setup GoogleServices
  3. Make GoogleServices change based on a variable, perhaps like so:
    <GoogleServicesJson Include="Platforms\Android\google-services-$(AppEnvironment).json" />
  4. Build once dotnet build xyz.csproj --property:AppEnvironment=Stage
  5. Do not dotnet clean
  6. Build a second time dotnet build xyz.csproj --property:AppEnvironment=Test
  7. The build skipped the ProcessGoogleServicesJson target, resulting in old configuration being used.

Did you find any workaround?

We use a workaround, that is not ideal.

	<Target Name="InvalidateGoogleServicesStamp" BeforeTargets="ProcessGoogleServicesJson">
		<Delete Files="$(IntermediateOutputPath)googsvcsjson.stamp" />
		<Message Text="InvalidateGoogleServicesStamp: Deleted stamp file." Importance="high" />
	</Target>	

Relevant log output

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions