Bug 59575 - The "XamlCTask" task failed unexpectedly error for iOS Ad-Hoc build only.
Summary: The "XamlCTask" task failed unexpectedly error for iOS Ad-Hoc build only.
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.4
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-09-19 07:04 UTC by mofadevs
Modified: 2017-10-31 17:50 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
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 or GitHub 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:
Status:
RESOLVED NOT_REPRODUCIBLE

Description mofadevs 2017-09-19 07:04:11 UTC
Hi there!

I am having a Xamarin.Forms app. When deploying on a device in debug mode, everything works fine. But if I try to build the very same project in Ad-Hoc mode, I keep getting the "The "XamlCTask" task failed unexpectedly." error.

My Environment:
VS2015
Xamarin.Forms 2.3.4.270

Complete Error and Server Stack Trace:
================================
<My app Path>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018: The "XamlCTask" task failed unexpectedly.
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018: System.IO.IOException: The process cannot access the file '<Path to my App>\<my app name>\<my app name>.iOS\obj\iPhone\Ad-Hoc\<myappname>iOS.exe' because it is being used by another process.
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018: 
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018: Server stack trace: 
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018:    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018:    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018:    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018:    at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018:    at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters)
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018:    at Xamarin.Forms.Build.Tasks.XamlCTask.Execute(IList`1& thrownExceptions)
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018:    at Xamarin.Forms.Build.Tasks.XamlTask.Execute()
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018:    at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018:    at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018: 
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018: Exception rethrown at [0]: 
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018:    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018:    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018:    at Microsoft.Build.Framework.ITask.Execute()
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
3><Path to my App>\packages\Xamarin.Forms.2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets(62,3): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Comment 1 Paul DiPietro [MSFT] 2017-09-19 13:35:57 UTC
Hi -- is this on any new project you create on your machine, or just this one in particular? Is this the latest version of VS2015? Do any of the following make any difference in your results?

- Close all VS instances, run 'tskill msbuild' (due to the one "it is being used by another process" error)
- Clean/rebuild of the solution
- Testing one of the prerelease builds
- If possible, attempting to do the same thing in VS2017, if you have it installed

The XamlCTask error is one that can come up from time to time but sometimes resolves itself by trying various things. If none of these help at all, then we may need to have this looked into further.
Comment 2 mofadevs 2017-09-20 09:29:35 UTC
Hello
-This is happening for all projects, apparently, since Xamarin.Forms 2.3.4.247
-This is the latest version of VS2015
-Close all VS instances, run 'tskill msbuild' (due to the one "it is being used by another process" error) made NO DIFFERENCE
-Clean/rebuild of the solution made NO DIFFERENCE
-Currently I do not have VS2017. VS2015 was running absolutely fine since a long time.

This happens only when an Ad-Hoc build is spinning. 

Thanks.
Comment 3 Greg Cadmes 2017-09-20 16:17:52 UTC
Somewhat related... as I don't think this is isolated to just iOS.

I simply followed Oren Novontny's example located here:
https://oren.codes/2017/04/23/using-xamarin-forms-with-net-standard-vs-2017-edition/

The only difference was that I changed the Xamarin.Forms version from his referenced version of 2.3.4.231 to 2.3.4.270.

Hoping this new issue is not related to this previous issue:
https://bugzilla.xamarin.com/show_bug.cgi?id=56220

I decided to create a single .NETStandard 1.4 library with no references. Build = success.

Add Xamarin.Forms reference with the following <ItemGroup>
<ItemGroup>
   <PackageReference Include="Xamarin.Forms" Version="2.3.4.270" />
</ItemGroup> 
Rebuild = success

Add Xamarin.Forms Android platform app.
Rebuild = success

Attempt to deploy
Rebuild = fail, 

...\"ClassLibrary1.dll' because it is being used by another process


Error List Contents:

Severity	Code	Description	Project	File	Line	Suppression State
Error	MSB4018	The "XamlCTask" task failed unexpectedly.
System.IO.IOException: The process cannot access the file 'C:\Projects\Research\_MLS_researach\Xamarin.Forms\ClassLibrary1\ClassLibrary1\obj\Debug\netstandard1.4\ClassLibrary1.dll' because it is being used by another process.

Server stack trace: 
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
   at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters)
   at Xamarin.Forms.Build.Tasks.XamlCTask.Execute(IList`1& thrownExceptions)
   at Xamarin.Forms.Build.Tasks.XamlTask.Execute()
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Microsoft.Build.Framework.ITask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()	ClassLibrary1	C:\Users\gcadmes\.nuget\packages\xamarin.forms\2.3.4.270\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets	62
Comment 4 Greg Cadmes 2017-09-20 16:20:18 UTC
Forgot to mention, I'm using Visual Studio 2017 v15.3.5
Xamarin 4.7.9.45
Xamarin.Android SDK 7.4.5.1
Xamarin.IOS/Mac SDK 11.0.0.0
Comment 5 Paul DiPietro [MSFT] 2017-10-31 17:50:57 UTC
As we have not received a reproduction and there haven't been other reports, this will be closed for the time being. Do please reopen this with a reproduction project we can use to investigate the issue if you're still experiencing the behavior as of the latest VS 15.4.1/X.A/X.I releases. Thanks!