Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AndroidEnvironment build task doesn't work properly when environment text file changes #8849

Open
BretJohnson opened this issue Apr 2, 2024 · 5 comments
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects. needs-triage Issues that need to be assigned.

Comments

@BretJohnson
Copy link
Contributor

Android application type

.NET Android (net7.0-android, net8.0-android, etc.)

Affected platform version

VS 2022 17.10 P2

Description

AndroidEnvironment environment variables aren't updated when the environment text file changes.

AndroidEnvTest_Debug_AnyCPU_net8.0-android_Build_2024-04-01T12_13_05.9187908-04_00.binlog.txt

Steps to Reproduce

  1. Clone https://github.com/BretJohnson/AndroidEnvTest
  2. Build & run it, on Android. Note that environment variables are output to Debug, e.g. ENV1=YYYY is in the Debug output on VS.
  3. Update myenv.txt, say changing the first line to be ENV1=NEWVALUE. Stop & restart, which triggers a build.

Result: Note that the Debug output still has ENV1-YYYY, not the new value.

Did you find any workaround?

No, not yet - and a workaround is what I'd most like here, so looking for hints on that.

Relevant log output

See attached binlog (renamed to have a .txt extension so I can attach it, but it's a .binlog).
@BretJohnson BretJohnson added Area: App+Library Build Issues when building Library projects or Application projects. needs-triage Issues that need to be assigned. labels Apr 2, 2024
@pjcollins
Copy link
Member

The corresponding target does appear to be set up to build incrementally correctly. _GeneratePackageManagerJava is fully rebuilt as shown below, but the updated environment contents do not make it into the app. Perhaps the issue lies somewhere in ApplicationConfigNativeAssemblyGenerator?

   1:7>Target "_GeneratePackageManagerJava" in file "/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.85/tools/Xamarin.Android.Common.targets" from project "/Users/peter/source/AndroidEnvTest/AndroidEnvTest.csproj" (target "_CompileJava" depends on it):
       Building target "_GeneratePackageManagerJava" completely.
       Input file "myenv.txt" is newer than output file "obj/Debug/net8.0-android/stamp/_GeneratePackageManagerJava.stamp".

Unfortunately after a quick look I can't think of an easy workaround without having to drop in a .dll with a patched _GeneratePackageManagerJava task, unless you want to delete your bin/obj folders in between builds temporarily...

@dellis1972
Copy link
Contributor

Looking at the logs even _CompileNativeAssemblySources is running.
This is part of the native side. I guess the app is not being deployed which is why the new values are not showing up.

@BretJohnson are you able to repo using the -t:Install target from the command line?

@BretJohnson
Copy link
Contributor Author

If I make C# code changes and restart those are applied, so the app must be getting redeployed.

@dellis1972
Copy link
Contributor

@BretJohnson I ment if you just change the myenv.txt file and then call -t:Install does that re-deploy the binaries?

@BretJohnson
Copy link
Contributor Author

I did that test: I updated myenv.txt and then did dotnet build -f net8.0-android -t:install -bl.
Here are the results:
msbuild.binlog.txt

jonathanpeppers pushed a commit that referenced this issue Apr 15, 2024
Context: #8849

Add a unit test to make sure we update the `environment.xxx.ll`
files when they are updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: App+Library Build Issues when building Library projects or Application projects. needs-triage Issues that need to be assigned.
Projects
None yet
Development

No branches or pull requests

4 participants