Skip to content

Conversation

jonathanpeppers
Copy link
Member

Backport of: #10351

If you run dotnet-trace collect --dsrouter android, it says:

Start an application on android device with ONE of the following environment variables set:
[Default Tracing]
DOTNET_DiagnosticPorts=127.0.0.1:9000,nosuspend,connect
[Startup Tracing]
DOTNET_DiagnosticPorts=127.0.0.1:9000,suspend,connect

Setting $DOTNET_DiagnosticPorts is non-trivial, so as a step to simplify this, we are adding multiple MSBuild properties to configure this value.

This would allow the log message to say:

Build and run an Android application such as:
[Default Tracing]
dotnet build -t:Run -c Release -p:DiagnosticAddress=127.0.0.1 -p:DiagnosticPort=9000 -p:DiagnosticSuspend=false -p:DiagnosticListenMode=connect
[Startup Tracing]
dotnet build -t:Run -c Release -p:DiagnosticAddress=127.0.0.1 -p:DiagnosticPort=9000 -p:DiagnosticSuspend=true -p:DiagnosticListenMode=connect

You could also set $(DiagnosticConfiguration), but you would need to escape the , character with %2c.

Setting any of the new properties also implicitly means that $(AndroidEnableProfiler) is set to true.

@jonathanpeppers jonathanpeppers enabled auto-merge (squash) July 31, 2025 16:28
…0351)

If you run `dotnet-trace collect --dsrouter android`, it says:

    Start an application on android device with ONE of the following environment variables set:
    [Default Tracing]
    DOTNET_DiagnosticPorts=127.0.0.1:9000,nosuspend,connect
    [Startup Tracing]
    DOTNET_DiagnosticPorts=127.0.0.1:9000,suspend,connect

Setting `$DOTNET_DiagnosticPorts` is non-trivial, so as a step to
simplify this, we are adding multiple MSBuild properties to configure
this value.

This would allow the log message to say:

    Build and run an Android application such as:
    [Default Tracing]
    dotnet build -t:Run -c Release -p:DiagnosticAddress=127.0.0.1 -p:DiagnosticPort=9000 -p:DiagnosticSuspend=false -p:DiagnosticListenMode=connect
    [Startup Tracing]
    dotnet build -t:Run -c Release -p:DiagnosticAddress=127.0.0.1 -p:DiagnosticPort=9000 -p:DiagnosticSuspend=true -p:DiagnosticListenMode=connect

You could also set `$(DiagnosticConfiguration)`, but you would need to
escape the `,` character with `%2c`.

Setting any of the new properties also implicitly means that
`$(AndroidEnableProfiler)` is set to `true`.
…#9451)

Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=10431207&view=ms.vss-test-web.build-test-results-tab&runId=114098346&resultId=100000&paneView=debug

The `FastDeployEnvironmentFiles(false)` test fails on PRs from forks,
because the "Fast Deployment" feature is not included in OSS builds:

	The Environment variable "DOTNET_MODIFIABLE_ASSEMBLIES" was not set.
	Expected: String containing "DOTNET_MODIFIABLE_ASSEMBLIES=Debug"
	But was:  "--------- beginning of main …

The problem appears to be related to target ordering:

  * `_GetGenerateJavaStubsInputs` : uses `@(AndroidEnvironment)` to
    set `@(_EnvironmentFiles)`

  * `_GetGenerateJavaStubs` : must have same `Inputs` as
    `_GeneratePackageManagerJava`

  * `_GeneratePackageManagerJava`: actually uses `@(_EnvironmentFiles)`

  * `_GenerateEnvironmentFiles` : creates a new
    `@(AndroidEnvironment)` file that won't be used!

But when using either a `Release` build or `Debug` build with
`FastDev` enabled, everything works fine.

To fix this, rework the target ordering:

  * `_GetGenerateJavaStubsInputs` depends on
    `_GenerateEnvironmentFiles`

    Unfortunately, this is now a circular dependency that causes an
    MSBuild error.

  * Break the cycle by updating `_GenerateEnvironmentFiles` to no
    longer depend upon `_ReadAndroidManifest`.

    It does not appear that `_ReadAndroidManifest` is needed by
    `_GenerateEnvironmentFiles`, as no properties created there are
    used.
@jonathanpeppers jonathanpeppers force-pushed the dev/peppers/backport-10351 branch from 8f2d983 to 599e09a Compare July 31, 2025 21:16
@jonathanpeppers
Copy link
Member Author

There is a networking-related http failure, we can ignore:

Mono.Android.NET_Tests, Xamarin.Android.NetTests.AndroidMessageHandlerIntegrationTests.HttpClientIntegrationTestBase.CancelRequestViaProxy / Debug

@jonathanpeppers jonathanpeppers merged commit d632706 into release/9.0.1xx Aug 1, 2025
55 of 57 checks passed
@jonathanpeppers jonathanpeppers deleted the dev/peppers/backport-10351 branch August 1, 2025 16:19
@github-actions github-actions bot locked and limited conversation to collaborators Sep 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant