Bug 48539 - MSBuild: Exec task doesn't work (InvalidOperationException)
Summary: MSBuild: Exec task doesn't work (InvalidOperationException)
Status: NEW
Alias: None
Product: Tools
Classification: Mono
Component: msbuild ()
Version: 4.6.0 (C8)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jose Gallardo
URL:
Depends on:
Blocks:
 
Reported: 2016-12-01 15:36 UTC by Sylvain Gravel
Modified: 2017-09-04 22:24 UTC (History)
6 users (show)

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


Attachments
iOS Project file (29.69 KB, text/plain)
2016-12-02 17:45 UTC, Sylvain Gravel
Details
Diagnostic log (4.14 MB, text/plain)
2016-12-02 17:50 UTC, Sylvain Gravel
Details


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 for Bug 48539 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Sylvain Gravel 2016-12-01 15:36:39 UTC
I'm trying to have a step in my build process to change my plist to allow opening random sites in debug (deactivating ATS)

So I added the following target in my iOS csproj to invoke PListBuddy :

```
 <Target Name="SetupPlist"
          BeforeTargets="_CompileToNative">
    <Exec Command="/usr/libexec/PlistBuddy -c 'Set :NSAppTransportSecurity:NSAllowsArbitraryLoads YES' '$(_AppBundlePath)Info.plist'"
    			SessionId="$(BuildSessionId)"
    	    Condition="'$(BuildSessionId)' != '' And
    	               ('$(Platform)' == 'iPhoneSimulator' Or
    	    					  ('$(Configuration)' != 'AppStore' And '$(Configuration)' != 'Ad-Hoc'))">

    </Exec>
</Target>
```

The command seems to run fine but I get an error which prevents a successful build : 

```
2>SetupPlist:
2>  Executing: /usr/libexec/PlistBuddy -c 'Set :NSAppTransportSecurity:NSAllowsArbitraryLoads YES' 'bin/iPhone/Debug/AppliOrange.iOS.app/Info.plist'
2>D:\Programmation\Xamarin\AppliOrange\AppliOrange\AppliOrange.iOS\AppliOrange.iOS.csproj(449,5): error : JsonSerializationException: Error setting value to 'StdOutEncoding' on 'Microsoft.Build.Tasks.Exec'.
2>D:\Programmation\Xamarin\AppliOrange\AppliOrange\AppliOrange.iOS\AppliOrange.iOS.csproj(449,5): error : InvalidOperationException: Task attempted to log before it was initialized. Message was: "Exec" task received an invalid value for the "StdOutEncoding" parameter.
2>D:\Programmation\Xamarin\AppliOrange\AppliOrange\AppliOrange.iOS\AppliOrange.iOS.csproj(449,5): error : 
2>
2>Build FAILED.
2>

```

Any clue?
Comment 1 Jeffrey Stedfast 2016-12-01 18:20:03 UTC
This looks like an issue with the Visual Studio side of things (serialization to send to the Mac side, perhaps?)
Comment 2 Sylvain Gravel 2016-12-02 15:28:15 UTC
Tried in Tamarin Studio and I get the following :

```
	Target SetupPlist:
		Executing: /usr/libexec/PlistBuddy -c 'Set :NSAppTransportSecurity:NSAllowsArbitraryLoads YES' 'bin/iPhoneSimulator/Debug/AppliOrange.iOS.app/Info.plist'
/Users/gulogulosoftware/Projects/AppliOrange/AppliOrange/AppliOrange.iOS/AppliOrange.iOS.csproj: error : Error executing task Exec: The parameter 'ConsoleOutput' was not found for the 'Exec' task.
		Build FAILED.
```
Comment 3 Jeffrey Stedfast 2016-12-02 17:04:15 UTC
Okay, then the problem is with xbuild and/or its Task implementations.

The iOS targets/tasks don't do anything with the Exec task.
Comment 4 Ankit Jain 2016-12-02 17:16:53 UTC
Sylvain, could you please share the project file - `AppliOrange/AppliOrange/AppliOrange.iOS/AppliOrange.iOS.csproj` ? I want to see the exact target definition that you have there.
Comment 5 Ankit Jain 2016-12-02 17:21:10 UTC
Also, could you please attach the full diagnostic build log, using https://developer.xamarin.com/guides/android/troubleshooting/troubleshooting/#Diagnostic_MSBuild_Output ?
Comment 6 Sylvain Gravel 2016-12-02 17:45:53 UTC
Created attachment 18757 [details]
iOS Project file

The task is commented out in this version
Comment 7 Sylvain Gravel 2016-12-02 17:50:04 UTC
Created attachment 18758 [details]
Diagnostic log

Diagnostic log
Comment 8 Marek Safar 2017-09-04 22:24:22 UTC
Resetting the status