The new complete fix has now been released to the stable channel:
QA has now also added tests for building with TFS to the stable release process to guard against this kind of issue reappearing in the future.
The Xamarin 3.7.226 hotfix release that was just published to the stable channel includes a patch that explicitly removes all of the read-only flags from resources as they are copied into the
Unfortunately the first test case I created for the bug report was foolishly not aggressive enough. I was basing the test case off the steps in another bug report, so it didn't cross my mind that there would be an important distinction between marking the whole
Resources\ folder read-only compared to just a few specific resources.
I've re-opened the bug report with a better test case and directly notified the developers about the remaining problem with the
*.xml.tmp files. Hopefully we can get a follow-up fix for this issue released very soon.
Xamarin 3.7.201 and Xamarin.Android 4.18 introduced a regression for resource files that are marked read-only on the file system. I've filed a high priority bug for the issue. Because many of the Xamarin developers are busy at Evolve this week, a hotfix for this issue might not make it out until next week.
This problem is particularly noticeable when using TFS because TFS automatically marks all of the resource files as read-only when it pulls them down from the source control server.
If you are performing a direct local build in Visual Studio for a solution that is under TFS source control, the following steps might be sufficient as a temporary workaround:
Resources\folder from TFS (recursively).
You can try removing the read-only flag from the
Resources\ folder and all of its contents by hand. You could for example create a copy of the solution entirely outside of TFS or SourceGear Vault, or remove just the
Resources\ folder from source control, and then use this technique.
If needed, you can use a "Pre-build event" to remove the read-only attributes at the start of each build, and then use a "Post-build event" command to put them back (under "Project Properties -> Build Events").
If you are using a TFS build agent, you will need to use some technique to remove the read-only attributes on the files after they have been copied to the build agent working directory (see for example ). If you are using TFS 2008 or earlier, this can be achieved using a "Pre-Build Event," as documented for the
Resource.Designer.cs file here: http://developer.xamarin.com/guides/cross-platform/ci/tfs_walkthrough/#Prepare_Xamarin.Android_for_TFS. If you are using TFS 2013, you can use a script similar to Alfonsi's suggestion below as a Pre-build PowerShell script.
Downgrade to Xamarin 3.6.262 (or earlier) for Windows:
If you use Xamarin.iOS, download this corrected
.targets file: https://s3.amazonaws.com/xvs.xamarin.com/Xamarin.iOS.Common.targets. (Steps 2 and 3 are needed to work around a bug in 3.6.262).
Copy the file into
C:\Program Files (x86)\MSBuild\Xamarin\iOS, overwriting the existing file. (This step requires administrator privileges.)
If you use Xamarin.iOS, you'll also need to downgrade the Mac build host to the matching version:
// Error 1 The "CopyAndConvertResources" task failed unexpectedly. // System.UnauthorizedAccessException: Access to the path 'C:\Users\Windows User\Desktop\AndroidApp1\AndroidApp1\obj\Debug\res\drawable\image1.png' is denied. // 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, Int32 bufferSize) // at System.IO.File.OpenFile(String path, FileAccess access, SafeFileHandle& handle) // at System.IO.File.SetLastWriteTimeUtc(String path, DateTime lastWriteTimeUtc) // at Xamarin.Android.Tasks.CopyAndConvertResources.Execute() // at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() // at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() AndroidApp1
At present, TFS is not included in Xamarin's stable release testing process. If you'd like to see this added as part of the testing process we'd highly recommend voting for it on Xamarin's UserVoice. In the absence of data about the number of users who need regression testing for TFS, plans to add TFS to the testing regimen will have to wait until Xamarin has grown to have some extra testing capacity. If TFS regression testing shows up as a highly demanded suggestion on UserVoice, it can be added to the testing regimen sooner.
EDIT October 8: Updated the workarounds a little based on the comments. Added a note about QA testing.
EDIT October 8: Added pre-build / post-build events suggestion to workaround 2.
EDIT October 16: Update to mention the Xamarin 3.7.226 hotfix build. Update workarounds and a distinction between TFS build agent builds and local "direct" builds.
EDIT October 30: New complete fix is now in the stable channel.