Skip to content

dotnet-watch requires MtouchLink=None for iOS Simulator projects #25295

Closed

Description

@jonathanpeppers

Description

dotnet watch does not work for iOS projects unless <MtouchLink>None</MtouchLink> is explicitly set in the .csproj file.

Without this setting, dotnet watch fails to work properly on iPhone Simulator builds.

Steps to Reproduce

  1. Create a new .NET iOS project
  2. Run dotnet watch targeting an iPhone Simulator
  3. Observe that it does not work

Workaround

Add the following to your .csproj:

<PropertyGroup>
  <MtouchLink>None</MtouchLink>
</PropertyGroup>

Proposal

We should consider making MtouchLink=None the default for Debug iPhone Simulator builds, since linking is not typically needed in that configuration and it blocks dotnet watch from working.

This would improve the inner development loop experience without affecting Release or device builds.

Activity

  1. rolfbjarne commented on May 4, 2026

    @rolfbjarne
    Member

    Trimming is disabled for simulator builds only if the interpreter is enabled (otherwise the build takes forever), which IIRC is the default for MAUI builds (and Hot Reload doesn't work anyway unless the interpreter is enabled I believe),

    <_DefaultLinkMode Condition="'$(_DefaultLinkMode)' == '' And '$(_SdkIsSimulator)' == 'true' And (!$(RuntimeIdentifier.Contains('arm64')) Or '$(MtouchInterpreter)' != '')">None</_DefaultLinkMode>

    Exactly which build configuration did you use? Was this just a 'dotnet new ios' or something else? Would you happen to have a binlog?

  2. added
    need-info
    on May 4, 2026
  3. added this to the Future milestone on May 4, 2026
  4. dotnet-policy-service commented on May 4, 2026

    @dotnet-policy-service

    Hi @jonathanpeppers. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

  5. jonathanpeppers commented on May 4, 2026

    @jonathanpeppers
    Author
  6. jonathanpeppers commented on May 4, 2026

    @jonathanpeppers
    MemberAuthor

    Sorry, it was a dotnet new maui project (.NET 11 Preview 4 builds), and if I don't set this property I get this exception in the startup hook:

    Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
     ---> System.MissingMethodException: Method not found: 'System.String[] System.Environment.GetCommandLineArgs()'.
       at StartupHook.Initialize()
       at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
       at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
       --- End of inner exception stack trace ---
       at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.StartupHookProvider.CallStartupHook(StartupHookNameOrPath startupHook)
       at System.StartupHookProvider.ProcessStartupHooks(String diagnosticStartupHooks)
       at System.StartupHookProvider.ManagedStartup(Char* pDiagnosticStartupHooks, Exception* pException)
    

    Confusing, but related, I found these lines in dotnet/maui:

  7. jonathanpeppers commented on May 4, 2026

    @jonathanpeppers
    MemberAuthor

    Oh, I forgot a .binlog:

    Archive.zip

  8. rolfbjarne commented on May 5, 2026

    @rolfbjarne
    Member

    Oh, I forgot a .binlog:

    Archive.zip

    So MAUI does this:

    <MtouchLink Condition="'$(MtouchLink)' == '' and '$(Configuration)' == 'Debug' and '$(UseMonoRuntime)' != 'true'">SdkOnly</MtouchLink>

    It's turning on the trimmer when using CoreCLR.

    This was implemented here: dotnet/maui#34107

  9. rolfbjarne commented on May 5, 2026

    @rolfbjarne
    Member

    I think this needs a change in MAUI as well.

  10. added a commit that references this issue on May 9, 2026
    8f5e478
  11. dotnet-policy-service commented on May 13, 2026

    @dotnet-policy-service

    Hi @jonathanpeppers. Due to inactivity, we will be closing this issue. Please feel free to re-open this issue if the issue persists. For enhanced visibility, if over 7 days have passed, please open a new issue and link this issue there. Thank you.

  12. removed this from the Future milestone on May 13, 2026
  13. removed
    need-info
    on May 13, 2026
  14. added this to the .NET 11 milestone on May 13, 2026
  15. rolfbjarne commented on Jul 16, 2026

    @rolfbjarne
    Member

    "dotnet watch" works from a plain "dotnet new maui" solution when targeting an iOS simulator in P6 now, no changes needed, so this is fixed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions