[Xamarin.Android.Build.Tasks] The "ConvertResourcesCases" task failed unexpectedly.#1371
Merged
jonpryor merged 3 commits intodotnet:masterfrom Mar 8, 2018
Merged
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.
jonpryor
reviewed
Mar 6, 2018
| Log.LogDebugMessage (" Processing: {0}", file); | ||
| var srcmodifiedDate = File.GetLastWriteTimeUtc (file); | ||
| var tmpdest = file + ".tmp"; | ||
| var tmpdest = file + "_" + Path.GetFileName (Path.GetTempFileName ()); |
Contributor
There was a problem hiding this comment.
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.
Contributor
|
The macOS+xbuild PR Build is failing: |
Contributor
Author
Contributor
|
@dean: sounds like we should crib the |
jonpryor
pushed a commit
that referenced
this pull request
Mar 9, 2018
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.