Skip to content

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

Open

Description

@BretJohnson

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).

Activity

  1. pjcollins commented on Apr 2, 2024

    @pjcollins
    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...

  2. dellis1972 commented on Apr 3, 2024

    @dellis1972
    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?

  3. BretJohnson commented on Apr 3, 2024

    @BretJohnson
    Author

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

  4. dellis1972 commented on Apr 3, 2024

    @dellis1972
    Contributor

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

  5. BretJohnson commented on Apr 3, 2024

    @BretJohnson
    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions