Skip to content

Commit 7418105

Browse files
dellis1972jonpryor
authored andcommitted
[Xamarin.Android.Build.Tasks] Use full path to create designer output directory. (#1542)
Fixes: #1541 We missed one area in the changes where we worked around the WorkingDirectory issues (45efffe): we were not using the full path to create the directory where the java `R.java` files are output. As a result we ended up with the following error: Error Access to the path 'obj\Debug\monoandroid81\android\src' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost) at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost) at System.IO.Directory.CreateDirectory(String path) at Xamarin.Android.Tasks.Aapt.GenerateCommandLineCommands(String ManifestFile, String currentAbi, String currentResourceOutputFile) at Xamarin.Android.Tasks.Aapt.ProcessManifest(ITaskItem manifestFile) Once again this is due to the working directory changing in the thread that we are using. So the solution is to use the full path to create the folder. In theory because we use the `WorkingDirectory` on the process we should NOT need to pass the full path as the command line argument. While that might be a safer option we might well run into issues were we exceed the max path or max command line length on Windows.
1 parent 3f7eca4 commit 7418105

File tree

1 file changed

+2
-1
lines changed
  • src/Xamarin.Android.Build.Tasks/Tasks

1 file changed

+2
-1
lines changed

src/Xamarin.Android.Build.Tasks/Tasks/Aapt.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ protected string GenerateCommandLineCommands (string ManifestFile, string curren
330330
manifest.Save (manifestFile);
331331

332332
cmd.AppendSwitchIfNotNull ("-M ", manifestFile);
333-
Directory.CreateDirectory (JavaDesignerOutputDirectory);
333+
var designerDirectory = Path.IsPathRooted (JavaDesignerOutputDirectory) ? JavaDesignerOutputDirectory : Path.Combine (WorkingDirectory, JavaDesignerOutputDirectory);
334+
Directory.CreateDirectory (designerDirectory);
334335
cmd.AppendSwitchIfNotNull ("-J ", JavaDesignerOutputDirectory);
335336

336337
if (PackageName != null)

0 commit comments

Comments
 (0)