Skip to content

[net10.0] [dotnet] Use the 'ComputeRunArguments' target to compute properties for 'dotnet run'. #22816

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

Merged
merged 3 commits into from
May 20, 2025

Conversation

rolfbjarne
Copy link
Member

In .NET 10 there's a new target we can hook into ("ComputeRunArguments") to do anything
we need to do before 'dotnet run' runs the target app.

For mobile (iOS and tvOS), we now run the "_PrepareRunMobile" target before "ComputeRunArguments",
and this will:

  • Install the app on device for device builds.
  • Run mlaunch to run launch the app on device or in the simulator.

For desktop (macOS and Mac Catalyst), we run the new "_PrepareRunDesktop" target
before "ComputeRunArguments" to set the RunCommand and RunArguments properties.
I've also added the capability to not launch apps on desktop with open, by setting
the property RunWithOpen=false.

Also add support for passing arguments to the app when running on iOS and tvOS (by
passing '-- <extra args' to mlaunch).

Fixes #12459.
Fixes #14845.

References:

…or 'dotnet run'.

In .NET 10 there's a new target we can hook into ("ComputeRunArguments") to do anything
we need to do before 'dotnet run' runs the target app.

For mobile (iOS and tvOS), we now run the "_PrepareRunMobile" target before "ComputeRunArguments",
and this will:

* Install the app on device for device builds.
* Run mlaunch to run launch the app on device or in the simulator.

For desktop (macOS and Mac Catalyst), we run the new "_PrepareRunDesktop" target
before "ComputeRunArguments" to set the `RunCommand` and `RunArguments` properties.
I've also added the capability to _not_ launch apps on desktop with `open`, by setting
the property `RunWithOpen=false`.

Also add support for passing arguments to the app when running on iOS and tvOS (by
passing '-- <extra args' to mlaunch).

Fixes #12459.
Fixes #14845.

References:
* dotnet/sdk#42155
* dotnet/android#9470
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

$ dotnet run -p:OpenNewInstance=false
```

### RunEnvironment
Copy link
Member

@dalexsoto dalexsoto May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about SetRunEnviromentVars or SetRunEnviromentArgs or SetEnviromentVars or SetEnviromentArgs? RunEnviroment seems easy to clash just like the case we had with NativeLibrary just my 2 cents, naming is hard heh

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this option completely, it's possible to do the same thing with the OpenArguments property, so document that instead.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #783ffc0] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 783ffc0142151c7faaeedad5125868e985790ea5 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #783ffc0] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 783ffc0142151c7faaeedad5125868e985790ea5 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

.NET ( No breaking changes )

✅ API diff vs stable

.NET ( No breaking changes )

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 783ffc0142151c7faaeedad5125868e985790ea5 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #783ffc0] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 783ffc0142151c7faaeedad5125868e985790ea5 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #783ffc0] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 783ffc0142151c7faaeedad5125868e985790ea5 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #783ffc0] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: 783ffc0142151c7faaeedad5125868e985790ea5 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #783ffc0] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: 783ffc0142151c7faaeedad5125868e985790ea5 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #783ffc0] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 783ffc0142151c7faaeedad5125868e985790ea5 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #783ffc0] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 124 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 6 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 10 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (macOS): All 12 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 10 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: 783ffc0142151c7faaeedad5125868e985790ea5 [PR build]

@rolfbjarne rolfbjarne merged commit df02b01 into net10.0 May 20, 2025
44 checks passed
@rolfbjarne rolfbjarne deleted the dev/rolf/dotnet-run branch May 20, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.NET: add support for passing arguments to mobile apps at launch Add proper support for 'dotnet run' for mobile targets
3 participants