Bug 9262 - The "CopyIfChanged" task failed unexpectedly when building project under source control
Summary: The "CopyIfChanged" task failed unexpectedly when building project under sour...
Status: RESOLVED NORESPONSE
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android ()
Version: unspecified
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-01-04 06:43 UTC by jimm@tbsmobility.com
Modified: 2016-08-03 15:22 UTC (History)
8 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 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 NORESPONSE

Description jimm@tbsmobility.com 2013-01-04 06:43:28 UTC
We have a mono-for-android project under TFS source control and when attempting to build the project we get the build error:

C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets(535,2): error MSB4018: The "CopyIfChanged" task failed unexpectedly.
C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets(535,2): error MSB4018: System.UnauthorizedAccessException: Access to the path 'Resources\Resource.Designer.cs' is denied.
C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets(535,2): error MSB4018:    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets(535,2): error MSB4018:    at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)
C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets(535,2): error MSB4018:    at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)
C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets(535,2): error MSB4018:    at Xamarin.Android.Tasks.CopyIfChanged.Execute()
C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets(535,2): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
C:\Program Files (x86)\MSBuild\Novell\Novell.MonoDroid.Common.targets(535,2): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)
Done executing task "CopyIfChanged" -- FAILED. (TaskId:1005)


This can be resolved by checking-out the file before attempting the build but that's not practical for our auto-build machine.  To resolve this, I added a pre-build event to the main project file to remove the read-only flag from the file:

attrib -r $(ProjectDir)Resources\Resource.Designer.cs

.. and this was working for local dev machines fine.  The TFS auto-build needed a bit more work as a TFS builds won't run the pre-build event which is annoying but fixable.

I updated the mono-for-android install recently and it now seems like the pre-build events aren't running on local dev machines anymore, causing the build to fail with the above error message again.

So, the bug: pre-build events are broken.

Ideally, I'd like the mono-for-android build process to remove the readonly flag itself so it can do it's thing and this will simplify the TFS autobuild process in the end.

Are there any plans to fix this?

Regards

Jim Makin
Comment 1 Jonathan Pryor 2013-01-31 10:06:20 UTC
> So, the bug: pre-build events are broken.

That seems highly unusual, because Mono for Android isn't in charge of executing pre-build events (or most build events in general), MSBuild is.

You may want to build your project with diagnostic logging enabled to see if your pre-build event is being executed at all; perhaps it's executing but is erroring out, thus _appearing_ to not be executed?

Nothing in Novell.MonoDroid.Common.targets should be interfering with MSBuild pre-build event processing.

As for Resources.Designer.cs, we should remove the need for that to be in the project entirely. That's been filed as bug #5870.
Comment 2 jimm@tbsmobility.com 2013-02-12 09:13:03 UTC
Ok. Thanks for the explanation. I switched on full build output logging and did a search in the 70k lines it produced.

It seems this problem is intermittent.  I've already had it fail a few times today and I've also had it work properly even when I manually set the read-only bit and do a full rebuild. I think I'm going to leave it and just use the manual way for the time being.  

Thanks for the info that this will be sorted eventually and cheers for the reply.
Comment 3 PJ 2013-11-19 17:05:14 UTC
This bug has been in the NEEDINFO state with no changes for the last 90 days. Can we put this back into the NEW or CONFIRMED state, or are we still awaiting response?

If there is no change in the status of this bug over the next two weeks, this bug will be marked as NORESPONSE.
Comment 4 PJ 2013-12-05 18:35:33 UTC
This bug has not been changed from the NEEDINFO state since my previous comment, marking as RESOLVED NORESPONSE.

Please feel free to REOPEN this bug at any time if you are still experiencing the issue. Please add the requested information and set the bug back to the NEW (or CONFIRMED) state.