Bug 47688 - [Xamarin Studio Parity and Run Configurations support] "Project Options > iOS Run Options > Environment Variables" and "Project Options > iOS Run Options > Parameters" currently have no effect when launching from Visual Studio
Summary: [Xamarin Studio Parity and Run Configurations support] "Project Options > iOS...
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: 4.2.0 (C8)
Hardware: PC Windows
: --- normal
Target Milestone: 15.4
Assignee: Adrian Alonso
Depends on: 55900
  Show dependency tree
Reported: 2016-11-23 04:12 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2017-07-05 21:24 UTC (History)
6 users (show)

Tags: RunOptions
Is this bug a regression?: No
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Brendan Zagaeski (Xamarin Team, assistant) 2016-11-23 04:12:15 UTC
[Xamarin Studio Parity and Run Configurations support] "Project Options > iOS Run Options > Environment Variables" and  "Project Options > iOS Run Options > Parameters" currently have no effect when launching from Visual Studio

In theory I believe the problems with both of these fields will be addressed all together by the work to provide the "Run Configurations" feature [1] in XamarinVS.

[1] https://developer.xamarin.com/releases/studio/xamarin.studio_6.1/xamarin.studio_6.1/#Run_Configurations

## Regression status: not a recent regression

BAD: XamarinVS 3.11.1594 (Cycle 5 SR 5)
BAD: XamarinVS 4.2.1     (Cycle 8 SR 1)

## Steps to replicate

1. Create a new single view iPhone application.

2. Set the active configuration to "Debug|iPhoneSimulator".

3. Navigate to "Project options > iOS Run Options > Environment Variables".

4. For "Name" and "Value" for the "Environment Variables" table add an entry:

Name:  foo
Value: bar

5. Under the "Parameters" field enter "baz".  (Note: The order of steps 5 and 6 is important due to a UI bug.  That bug is separate from the main concern of this bug report and should in theory be fixed by the in-progress work to reimplement the iOS property panes.)

6. Save the project properties.

7. Add the following lines in the AppDelegate.FinishedLaunching override method:

NSObject x = NSProcessInfo.ProcessInfo.Environment["foo"];
if (x != null) {
    System.Console.WriteLine("Env: 'foo': '{0}'", x.ToString());

foreach (string arg in NSProcessInfo.ProcessInfo.Arguments)
    System.Console.WriteLine("Arg: {0}", arg);

8. Run the app on simulator.

## "Bad" results in Visual Studio

None of the output lines in the console output from the running app include any of the expected strings "foo", "bar", or "baz".

## "Good" results in Xamarin Studio on Mac

The console output from the running app includes the following 2 lines, showing that both the "Environment Variables" and "Parameters" configuration properties worked as expected:

> Env: 'foo': 'bar'
> Arg: -app-arg=baz

(The output also contains several other "Arg" lines, but those can be ignored for the purposes of this bug report.)

## Additional testing environment version info (brief)

### Windows

XamarinVS (680125b)

Microsoft Visual Studio Enterprise 2015
Version 14.0.25425.01 Update 3
Microsoft .NET Framework
Version 4.6.01055

Windows 8.1, Version 6.3 (Build 9600)

Language and Locale: US English
Username: "Windows User"
Timezone: US Eastern (UTC-5)

### Mac

Xamarin Studio (0ccfcd52b95305ebd5b7eca0d88c1017035910ae) (Build date: 2016-10-28 15:12:43-04)

Xamarin.iOS (316e533)
Mono 4.6.2 (mono-4.6.0-branch/08fd525)

Xcode 8.1 (11544), Build 8B62
Mac OS X 10.11.6

(Additional testing note: It appears that the "Parameters" field was not working in Xamarin Studio either in Xamarin Studio 6.0 (Cycle 7 SR 1), but that seems to have been remedied during the addition of the Run Configurations feature in Xamarin Studio for Cycle 8.)
Comment 2 Jose Gallardo 2016-12-27 21:37:45 UTC
We need to include this support as part of the Property pages improvements for C10.
Setting the target milestone accordingly.

Comment 3 Emanuel 2017-06-09 21:41:09 UTC

*** This bug has been marked as a duplicate of bug 55900 ***
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2017-06-09 22:09:54 UTC
## Bookkeeping note

I am reopening this bug because Bug 55900 is about the "UI bug" I mentioned in step 5.  As I stated "That bug is separate from the main concern of this bug report."  In the test scenario I described in Comment 0, the .csproj includes the following lines after step 6:

        <Variable name="foo" value="bar" />

And re-opening the "iOS Run Options" section of the project properties shows the expected value, indicating that it was indeed saved.  I will mark this bug as dependent on non-public Bug 55900.  If the XamarinVS team fixes _both_ bugs at the same time, that's fine.  I will happily verify this bug once the candidate fix is available.  In the mean time, this bug is a noticeably different symptom, so I will keep it open.  Thanks!