Bug 36407 - [XVS 4.0] "System.IO.FileNotFoundException ... does not exist" error during "_CopyResourcesToBundle" for BundleResource files located in a subdirectory of an iOS class library when the iOS app project references the Microsoft BCL Build NuGet package
Summary: [XVS 4.0] "System.IO.FileNotFoundException ... does not exist" error during "...
Status: VERIFIED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: 4.0.0 (C6)
Hardware: PC Windows
: --- normal
Target Milestone: 4.0.1 (C6SR1)
Assignee: Brendan Zagaeski (Xamarin Team, assistant)
URL:
: 36656 ()
Depends on:
Blocks:
 
Reported: 2015-12-01 08:51 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2016-07-25 19:05 UTC (History)
6 users (show)

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


Attachments
Test case (19.47 KB, application/zip)
2015-12-01 08:51 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details
Diagnostic build output and detailed version info (147.34 KB, application/zip)
2015-12-01 08:52 UTC, Brendan Zagaeski (Xamarin Team, assistant)
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 Brendan Zagaeski (Xamarin Team, assistant) 2015-12-01 08:51:23 UTC
Created attachment 14053 [details]
Test case

[XVS 4.0] "System.IO.FileNotFoundException ... does not exist" error during "_CopyResourcesToBundle" for BundleResource files located in a subdirectory of an iOS class library when the iOS app project references the Microsoft BCL Build NuGet package




## Possible workarounds that were observed to stop the problem

### Option 1

Move the BundleResource files to the root directory of the class library project. For example, in the attached test case move the `datacell.png` file out of both the "Images" and "Calendar" folders so that it sits in the root directory of the class library.


### Option 2

Set the "LogicalName" for the BundleResource files to be at the root directory of the class library project by hand-editing the `.csproj` file. For example, in the attached test case:

> <BundleResource Include="Images\Calendar\datecell.png">
>   <LogicalName>datecell.png</LogicalName>
> </BundleResource>

(Remove the > greater-than characters from the beginning of each line.)




## Regression status: regression in XVS 4.0

BAD:  XamarinVS 4.0.0.1708  (be53781) + Xamarin.iOS 9.2.1.52 (d070a7b)
BAD:  XamarinVS 4.0.0.1689  (f860fe4) + Xamarin.iOS 9.2.1.52 (d070a7b)
GOOD: XamarinVS 3.11.1594.0 (a06d6d5) + Xamarin.iOS 9.1.0.27 (1f068b4)




## Steps to reproduce

Attempt to build the attached test case in the "Debug|iPhoneSimulator" configuration while paired with the Mac build host.


(The test case is a new from template iOS app project and class library project, with the Microsoft BCL Build NuGet added to the iOS app project but with the "Import" statement then moved by hand above the Xamarin.iOS "Import" statement in the `.csproj` file. The `datecell.png` file is just a blank white square.)




## Result

The build fails because a BundleResource referenced in the class library is not copied into an expected intermediate location in the iOS app project build cache folder:

> System.IO.FileNotFoundException: /Volumes/Cases/macuser/Library/Caches/Xamarin/mtbs/builds/UnifiedSingleViewIphone1/e7d7aad18d3be7bdcfa899275391a776/obj/iPhone/Debug/Images/Calendar/datecell.png does not exist
> File name: '/Volumes/Cases/macuser/Library/Caches/Xamarin/mtbs/builds/UnifiedSingleViewIphone1/e7d7aad18d3be7bdcfa899275391a776/obj/iPhone/Debug/Images/Calendar/datecell.png'
>   at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, Boolean overwrite) <0x19ff7f0 + 0x00333> in <filename unknown>:0 
>   at Xamarin.MacDev.Tasks.SmartCopyTaskBase.CopyFile (System.String source, System.String target, System.String targetItemSpec) <0x39db900 + 0x000c7> in <filename unknown>:0 
>   at Xamarin.MacDev.Tasks.SmartCopyTaskBase.Execute () <0x39db1e8 + 0x00227> in <filename unknown>:0 



### The build cache folder contains the "correct" file, but named using the incorrect file path separators

> $ find obj/iPhoneSimulator/Debug -name "*.png"
> obj/iPhoneSimulator/Debug/Images\Calendar\datecell.png
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2015-12-01 08:52:11 UTC
Created attachment 14054 [details]
Diagnostic build output and detailed version info
Comment 4 Adrian Alonso 2015-12-01 14:53:03 UTC
@Brendan: I'm being able to build the attached solution successfully with the latest build form master. Could you please check if you can reproduce the issue with that build too? Thanks, Adrian
Comment 5 Adrian Alonso 2015-12-01 15:20:08 UTC
@Brendan: After disconnecting the network and rebuilding the project I was able to have a repro.
Comment 6 xamarin-release-manager 2015-12-01 19:27:35 UTC
Fixed in version 99.0.0.808 (master)

Author: Adrian Alonso
Commit: 42b3104c584ed1b61c97bd06006adca9ef4431cf (xamarin/XamarinVS)
Comment 7 xamarin-release-manager 2015-12-01 19:35:28 UTC
Fixed in version 4.0.1.22 (cycle6)

Author: Adrian Alonso
Commit: e34559589586e0215d7ff68039598f056ceedbff (xamarin/XamarinVS)
Comment 9 Brendan Zagaeski (Xamarin Team, assistant) 2016-02-10 00:34:01 UTC
## Status update

I have now verified that the test case and steps to reproduce from Comment 0 work correctly on XamarinVS 4.0.1.93 + Xamarin.iOS 9.4.1.25.




## Complication for libraries that were compiled using the older affected versions of Xamarin

Any Xamarin.iOS libraries that were built against one of the older "bad" versions of Xamarin will have the incorrect paths stored within the library itself. These libraries will need to be rebuilt using the latest version of Xamarin to fix the paths.



One way to identify this problem is to look at the Manifest in the `.dll` file using `ildasm`. For example, for the attached test case, the bad path appears in the Manifest as:

> .mresource public __monotouch_content_Images_bCalendar_bdatecell.png


... while the good path appears as:

> .mresource public __monotouch_content_Images_fCalendar_fdatecell.png

(Note how the `b` prefixes have been replaced by `f` prefixes.)




## Example of the complication: the third-party XLabs.Forms library, version 2.0.5783-pre01

By a bit of misfortune, the current pre-release version of the third-party XLabs.Forms NuGet package (2.0.5783-pre01) hits this complication. Specifically, the pre-release version of the `XLabs.Forms.iOS.dll` assembly was built using one of the affected versions of Xamarin. That assembly will need to be rebuilt using the latest version of Xamarin to correct the bad paths.
Comment 10 Brendan Zagaeski (Xamarin Team, assistant) 2016-02-23 22:26:56 UTC
*** Bug 36656 has been marked as a duplicate of this bug. ***
Comment 11 Pooja singh 2016-07-25 19:05:14 UTC
I was getting this error for datecell.png , I found that this is because of the xLabs.forms version: 2.0.5283-pre01 , so I updated version to 2.0.5282 and I was able to compile :)