-
Notifications
You must be signed in to change notification settings - Fork 564
[Xamarin.Android.Build.Tasks] The "ConvertResourcesCases" task failed unexpectedly. #1371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… unexpectedly. DevDiv Issue 571365 We have a report that `ConvertResourcesCases` is failing with the follow error. error MSB4018: The "ConvertResourcesCases" task failed unexpectedly. Android/Xamarin.Android.Common.targets(1334,2): error MSB4018: System.IO.FileNotFoundException: <some path>/design_layout_snackbar.xml.tmp does not exist This is completely weird, especially as the Task is not called in parallel. What I susepct is happening is VSForMac is running is UpdateResources task at the same time the user is doing a build. Because the name of the temp files we are just `foo.xml.tmp` it is highly possible that one instance of the task is deleting the file while the other instance is still running. This is difficult to replicate. This change uses System.IO.Path.GetFileName (System.IO.Path.GetTempFileName ()); to generate a random temp file name for the temp file. This should stop filename collisions.
| Log.LogDebugMessage (" Processing: {0}", file); | ||
| var srcmodifiedDate = File.GetLastWriteTimeUtc (file); | ||
| var tmpdest = file + ".tmp"; | ||
| var tmpdest = file + "_" + Path.GetFileName (Path.GetTempFileName ()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair idea, not-quite-write implementation.
Did you know that Path.GetTempFileName() creates the file?
This method creates a temporary file with a .TMP file extension.
For example:
var p = Path.GetTempFileName();
// p == e.g. "/var/folders/1y/wwmg3hv5685ft661f5q2w2100000gn/T/tmpa1d2e05.tmp"
File.Exists(p); // is trueAs such, Path.GetFileName(Path.GetTempFileName()) will "litter" the user's %TMPDIR% directory with temporary files which are never deleted.
Instead, we should just do:
var tempest = Path.GetTempFileName ();We'll properly delete this file in the finally block below.
|
The macOS+xbuild PR Build is failing: |
|
@dean: sounds like we should crib the |
… unexpectedly. (#1371) Fixes? https://devdiv.visualstudio.com/DevDiv/_workitems/edit/571365 We have a report that `ConvertResourcesCases` is failing with the following error: error MSB4018: The "ConvertResourcesCases" task failed unexpectedly. Android/Xamarin.Android.Common.targets(1334,2): error MSB4018: System.IO.FileNotFoundException: <some path>/design_layout_snackbar.xml.tmp does not exist This is completely weird, especially as the Task is not being called concurrently (or so we hope & assume). What I suspect is happening is Visual Studio for Mac is running the `UpdateAndroidResources` target at the same time the user started a build. Because the name of the temp files was just `foo.xml.tmp` it is highly possible that one instance of the task is deleting the file while another instance is still running. This is difficult to replicate. Attempt to "fix" things by using `System.IO.Path.GetTempFileName()` instead of appending `.tmp` to the filename. This should avoid filename collisions. However, if our suspicion is correct that the `UpdateAndroidResources` target is concurrently executing alongside a Build, this patch will *not* fix the concurrent target execution scenario.
DevDiv Issue 571365
We have a report that
ConvertResourcesCasesis failing with the followerror.
This is completely weird, especially as the Task is not called in
parallel. What I susepct is happening is VSForMac is running is
UpdateResources task at the same time the user is doing a build.
Because the name of the temp files we are just
foo.xml.tmpitis highly possible that one instance of the task is deleting the
file while the other instance is still running. This is difficult
to replicate.
This change uses
to generate a random temp file name for the temp file. This should
stop filename collisions since the file will end up in the
/tmpdirectory.