Bug 32608 - "System.IO.FileNotFoundException ... does not exist" build error for BundleResources located in subdirectories of iOS Bindings Libraries
Summary: "System.IO.FileNotFoundException ... does not exist" build error for BundleRe...
Status: VERIFIED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: 4.0.0 (C6)
Hardware: PC Windows
: Normal normal
Target Milestone: 4.1.0 (C7)
Assignee: Juan Marcelo Tondato
URL:
Depends on:
Blocks:
 
Reported: 2015-07-30 10:08 UTC by Philipp Schuster
Modified: 2016-05-20 16:29 UTC (History)
8 users (show)

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


Attachments
Zip Xamarin Logs (1.32 MB, application/octet-stream)
2015-08-06 11:24 UTC, Udham Singh
Details
Test Project (27.13 KB, application/zip)
2015-09-08 15:46 UTC, Jon Goldberger [MSFT]
Details
Screenshots of obj folder in Finder when built from VS and XS showing differing paths/filenames (142.91 KB, application/zip)
2015-09-08 15:54 UTC, Jon Goldberger [MSFT]
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 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:
VERIFIED FIXED

Description Philipp Schuster 2015-07-30 10:08:02 UTC
In an iOS Binding Project in Visual Studio in the Resources folder I have another folder that contains an image file.

MyProject
|_Resources
  |_SomeFolder
    |_SomeImage.png

The build action for SomeImage.png is BundleResource. When building a project that uses this project the build fails with FileNotFoundException for the path "/Users/MyUserName/Library/Caches/Xamarin/mtbs/builds/MyProject/2776c527595b9d813bd1cb5d68f59878/obj/iPhoneSimulator/Debug/SomeFolder/SomeImage.png".

A file 'SomeFolder\SomeImage.png' is present in the 'Debug' folder which may or may not be relevant.

A workaround is instead of adding the resources to the binding project to add them to the using project.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-07-31 04:35:02 UTC
I'm fairly sure binding projects don't support BundleResource resources, but @jeff: can you confirm?
Comment 2 Udham Singh 2015-08-06 11:24:51 UTC
Created attachment 12385 [details]
Zip Xamarin Logs

I have checked this issue and able to reproduce the reported behaviour.

Screencast : http://www.screencast.com/t/pi6OhNHZJjq

Build Output : https://gist.github.com/Udham1/9898e8442df9a7949e32

Environment Info : 

Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.50938

Installed Version: Professional

Xamarin   3.11.850.0 (5c48f6b)
Xamarin.Android   5.1.5.3 (f98871a95a479f6d71b3067b7e5834d41fcb2118)
Xamarin.iOS   8.10.4.0 (a888f9e906e136062b2de4a6b738787daae4e824)
Comment 3 Jeffrey Stedfast 2015-08-06 11:45:13 UTC
AFAICT everything is working properly.

Maybe this is a VS bug?
Comment 4 Jon Goldberger [MSFT] 2015-09-08 15:46:21 UTC
Created attachment 12829 [details]
Test Project

I have another customer hitting this issue. As far as I can tell BundleResources should be supported as this works in Xamarin Studio on the Mac, just not in VS. 

Binding project Resources folder has a setup like:
Resources
--Test
--Test.bundle

Where Test and test.bundle are subfolders of the Resources folder in the binding project and contain some resource files with Build Action set to BundleResource. 

In Xamarin Studio on the Mac:
This builds as expected and the resources do end up in the final app bundle. In the root directory of the App bundle you will see a subfolder Test with the resources that were in the Test subfolder and a Test.bundle package that contains the resources that were in the Test.bundle subfolder. 

In Visual Studio, the app project's build fails with error messages about not finding the resource files with an error message like:

>Error	1	System.IO.FileNotFoundException: /Users/apple/Library/Caches/Xamarin/mtbs/builds/TestBindingResourcesSample/b79fcd8e1a332f7a44b927d2282aea6b/obj/iPhoneSimulator/Debug/Test/button_black_135x40.png does not exist
>File name: '/Users/apple/Library/Caches/Xamarin/mtbs/builds/TestBindingResourcesSample/b79fcd8e1a332f7a44b927d2282aea6b/obj/iPhoneSimulator/Debug/Test/button_black_135x40.png'
>  at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, Boolean overwrite) [0x00000] in <filename unknown>:0 
>  at Xamarin.MacDev.Tasks.SmartCopyTaskBase.CopyFile (System.String source, System.String target, System.String targetItemSpec) [0x00000] in <filename unknown>:0 
>  at Xamarin.MacDev.Tasks.SmartCopyTaskBase.Execute () [0x00000] in <filename unknown>:0 	C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets	244	3	TestBindingResourcesSample

Looking in the build host cache, I see the file but it have a name such as:
Test\button_black_135x40.png

IOW the image resource is not placed in a subfolder called Test in the obj/[iPhone|iPhoneSimulator]/Debug folder but rather a file name is created that includes the Folder name, a backslash (windows style) and then the file name. 

I have added a simple test project that demonstrates this. It fails to build form Visual Studio but succeeds from Xamarin Studio. 

## Steps to reproduce

1. Open the attached sample and build all. 

Expected result: App project will build and the resources will be in the app bundle.

Actual result: App project build fails with above noted error. 


## Note

Again note that the same solution builds fine with Xamarin Studio.


##My environment:

Microsoft Visual Studio Ultimate 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.6.00057

Installed Version: Ultimate

Architecture and Modeling Tools   06181-004-0451031-02209
Microsoft Architecture and Modeling Tools
    
UML® and Unified Modeling Language™ are trademarks or registered trademarks of the Object Management Group, Inc. in the United States and other countries.

LightSwitch for Visual Studio 2013   06181-004-0451031-02209
Microsoft LightSwitch for Visual Studio 2013

Team Explorer for Visual Studio 2013   06181-004-0451031-02209
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06181-004-0451031-02209
Microsoft Visual Basic 2013

Visual C# 2013   06181-004-0451031-02209
Microsoft Visual C# 2013

Visual C++ 2013   06181-004-0451031-02209
Microsoft Visual C++ 2013

Visual F# 2013   06181-004-0451031-02209
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06181-004-0451031-02209
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06181-004-0451031-02209
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools   12.4.60425.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Web Apps
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.21010.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.4
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Advertising SDK for Windows Phone   
Microsoft Advertising SDK for Windows Phone
Build 

Microsoft Azure HDInsight HQL Service   2.0.1000.0
Language service for Hive query

Microsoft Azure HDInsight Tools for Visual Studio   2.0.1000.0
An integrated development environment for HDInsight application development.

Microsoft Azure Mobile Services Tools   1.3
Microsoft Azure Mobile Services Tools

Microsoft Azure Tools   2.6
Microsoft Azure Tools for Microsoft Visual Studio 2013 - v2.6.30508.1601

Microsoft Azure Tools   2.4
Microsoft Azure Tools for Microsoft Visual Studio 2013 - v2.4.20730.1601

Microsoft Azure Tools   2.5
Microsoft Azure Tools for Microsoft Visual Studio 2013 - v2.5.30319.1603

Multilingual App Toolkit   3.1.1250.0
Multilingual App Toolkit helps you localize your Windows Store app by providing file management, pseudo and machine translation, translation editor, and build integration. http://go.microsoft.com/fwlink?linkid=245767

NuGet Package Manager   2.8.60318.734
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2013 ENU   12.0.31105
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   12.0.41025.0
Microsoft SQL Server Data Tools

Windows Azure Tools   2.3
Windows Azure Tools for Microsoft Visual Studio 2013 - v2.3.20320.1602

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin   3.11.837.0 (f10676f)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   5.1.5.3 (f98871a95a479f6d71b3067b7e5834d41fcb2118)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.Forms Intellisense   1.0
Provides intellisense for Xamarin.Forms in the XML editor.

Xamarin.iOS   8.10.4.0 (6db87c53c073f4af2f5247fb738a27ea08c094fd)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

Xamarin.TestCloud.Integration   1.0
Early preview of Xamarin Test Cloud integration
Comment 5 Jon Goldberger [MSFT] 2015-09-08 15:54:34 UTC
Created attachment 12830 [details]
Screenshots of obj folder in Finder when built from VS and XS showing differing paths/filenames

Here are a couple of screenshots showing the differences in a build from VS and  a build from XS (Mac) for the same project. You can see how form XS you have a Test subfolder with the files in it but from VS you have now Test subfolder but instead have filenames that include the name of the subfolder with a backslash.
Comment 6 Jon Goldberger [MSFT] 2015-09-08 16:08:00 UTC
Correction for clarity:
"... You can see how from XS you have a Test subfolder with the files in it but from VS here is no Test subfolder but instead there are filenames that include the name of the subfolder with a backslash."
Comment 7 Brendan Zagaeski (Xamarin Team, assistant) 2015-12-17 04:48:26 UTC
## Regression status: not an immediate regression

BAD: XamarinVS 4.0.1.68    (96e2025) + Xamarin.iOS 9.4.1.0  (dab1554)
BAD: XamarinVS 3.11.1594.0 (a06d6d5) + Xamarin.iOS 9.1.0.27 (1f068b4)


The behavior of the test case from Comment 4 is approximately the same in "Cycle 5 – Service Release 5."




## Additional note to the Xamarin team

This looks similar to Bug 36407 (for plain iOS class libraries), but the fix for Bug 36407 is already included in XamarinVS 4.0.1.68 (96e2025). Perhaps approximately the same fix can be applied in one more place to solve this issue for bindings libraries too?
Comment 8 xamarin-release-manager 2016-01-05 14:27:33 UTC
Fixed in version 99.0.0.1029 (master)

Author: jmt
Commit: 84750212ebca21554ef972d8ab295cb9f61ffd93 (xamarin/XamarinVS)