This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 35613 - error MSB4018: System.NotSupportedException: The given path's format is not supported.
Summary: error MSB4018: System.NotSupportedException: The given path's format is not s...
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild (show other bugs)
Version: 5.1
Hardware: PC Mac OS
: Normal normal
Target Milestone: 6.1 (C7)
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2015-11-06 04:15 UTC by Prashant Cholachagudda
Modified: 2016-05-28 13:46 UTC (History)
5 users (show)

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


Attachments
Build log (2.15 MB, text/plain)
2015-11-06 04:15 UTC, Prashant Cholachagudda
Details
Android project diff file. (1.65 KB, application/octet-stream)
2015-11-24 08:52 UTC, Tibor Ebner
Details
Android project file in its before-the-issue form. (51.02 KB, text/plain)
2015-11-24 09:07 UTC, Tibor Ebner
Details
Patched Xamarin.Android.Common.targets (119.04 KB, text/html)
2015-11-30 11:45 UTC, dean.ellis
Details

Description Prashant Cholachagudda 2015-11-06 04:15:06 UTC
Created attachment 13701 [details]
Build log

Building the PCLCrypto[1] fails with below exception

error MSB4018: The "GenerateJavaStubs" task failed unexpectedly.\r [C:\Users\andarno\git\PCLCrypto\src\PCLCrypto.Tests.Android\PCLCrypto.Tests.Android.csproj]
System.NotSupportedException: The given path's format is not supported.\r [C:\Users\andarno\git\PCLCrypto\src\PCLCrypto.Tests.Android\PCLCrypto.Tests.Android.csproj]
   at System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String fullPath, Boolean checkForDuplicates, Boolean needFullPath)\r [C:\Users\andarno\git\PCLCrypto\src\PCLCrypto.Tests.Android\PCLCrypto.Tests.Android.csproj]
   at System.IO.Path.GetFullPath(String path)\r [C:\Users\andarno\git\PCLCrypto\src\PCLCrypto.Tests.Android\PCLCrypto.Tests.Android.csproj]
   at Xamarin.Android.Tasks.GenerateJavaStubs.Run()\r [C:\Users\andarno\git\PCLCrypto\src\PCLCrypto.Tests.Android\PCLCrypto.Tests.Android.csproj]
   at Xamarin.Android.Tasks.GenerateJavaStubs.Execute()\r [C:\Users\andarno\git\PCLCrypto\src\PCLCrypto.Tests.Android\PCLCrypto.Tests.Android.csproj]
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()\r [C:\Users\andarno\git\PCLCrypto\src\PCLCrypto.Tests.Android\PCLCrypto.Tests.Android.csproj]
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [C:\Users\andarno\git\PCLCrypto\src\PCLCrypto.Tests.Android\PCLCrypto.Tests.Android.csproj]

1. https://github.com/AArnott/PCLCrypto
Comment 1 Jonathan Pryor 2015-11-06 12:32:35 UTC
Based on the stack trace, we're assuming that ITaskItem.ItemSpec is a path, e.g.

    res.Load (Path.GetFullPath (assembly.ItemSpec));

I believe that ITaskItem.ItemSpec is the value of the //Reference/@Include attribute, which for some of the references are fully-qualified assembly names:

https://github.com/AArnott/PCLCrypto/blob/master/src/PCLCrypto.Tests.Android/PCLCrypto.Tests.Android.csproj#L92-L95

>     <Reference Include="Validation, Version=2.2.0.0, Culture=neutral, PublicKeyToken=2fc06f0d701809a7, processorArchitecture=MSIL">
>       <HintPath>..\..\packages\Validation.2.2.8\lib\dotnet\Validation.dll</HintPath>
>       <Private>True</Private>
>     </Reference>

As a guess, perhaps this is the problem?

As a workaround, please try editing your .csproj so that it uses correct paths for //Reference/@Include, and see if that fixes the problem.

@Dean: Assuming the above guesses are correct, we need to fixup the GenerateJavaStubs task to look at the %(Reference.HintPath) metadata, as we do in GenerateResourceDesigner.
Comment 2 Andrew Arnott 2015-11-07 11:24:02 UTC
Reference item's Include values are *frequently* not paths, but asssembly names. They may be fully-qualified assembly names as this one is, or they may be simple names like 'mscorlib'. There may not be a HintPath metadata as well. 

If you depend on paths to assemblies, you should *not* read Reference items, but rather read ReferencePath items (after the ResolveReferences target has executed).
Comment 3 Andrew Arnott 2015-11-07 19:44:43 UTC
Given Xamarin.Forms and many other NuGet packages all have this behavior, it's hard to imagine that XA is just broken when references such as these exist.
Comment 4 Andrew Arnott 2015-11-08 22:25:18 UTC
I found the problem. My project defines the BaseIntermediateOutputPath MSBuild property in terms of an absolute path. Apparently Xamarin.Android app projects fail to build with this error unless it is a relative path.

Can you please fix that bug? In the meantime, I can workaround.
Comment 5 dean.ellis 2015-11-12 17:26:02 UTC
Hi Andrew

I'll try to put together a unit test for with a absolute BaseIntermediateOutputPath and see if we can repo the issue, once we've done that we can move on to fixing it :)

Dean
Comment 6 Tibor Ebner 2015-11-24 07:36:54 UTC
I'm having the same issue:

C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018: The "GenerateJavaStubs" task failed unexpectedly.
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018: System.NotSupportedException: The given path's format is not supported.
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at System.IO.Path.GetFullPath(String path)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at Xamarin.Android.Tasks.GenerateJavaStubs.Run()
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at Xamarin.Android.Tasks.GenerateJavaStubs.Execute()
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1592,3): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()

=== Xamarin Studio ===

Version 5.10 (build 871)
Installation UUID: c6eee852-199d-4124-9043-43a061cc9e2d
Runtime:
	Microsoft .NET 4.0.30319.34209
	GTK+ 2.24.23 (MS-Windows theme)
	GTK# 2.12.30

=== Xamarin.Profiler ===

Not Installed

=== Xamarin.Android ===

Version: 6.0.0 (Indie Edition)
Android SDK: C:\Users\adinatha\Android\sdk
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)

SDK Tools Version: 24.4.1

SDK Platform Tools Version: 23.0.1

SDK Build Tools Version: 22.0.1


Java SDK: C:\Program Files\Java\jdk1.7.0_79
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

=== Xamarin Android Player ===

Not Installed

=== Build Information ===

Release ID: 510000871
Git revision: 4e9c5abb5ffdae12ba02ac49da83f8b2011dbb88
Build date: 2015-11-12 07:16:34-05
Xamarin addins: 55007ed0e56436f385d8e26394a45be563abc7e8
Build lane: monodevelop-windows-cycle6

=== Operating System ===

Windows 6.1.7601.65536 (64-bit)
Comment 7 Tibor Ebner 2015-11-24 07:52:48 UTC
Please try to fix this as soon as possible because as it stands today we can't release new versions of our app. We can't wait for weeks.
Comment 8 dean.ellis 2015-11-24 07:56:07 UTC
@Tibor does your project(s) define the BaseIntermediateOutputPath as an absolute path? That seemed to be the root cause of the problem for Andrew.
Comment 9 Tibor Ebner 2015-11-24 08:50:46 UTC
Hi Dean, it doesn't define that variable, I've already checked that. However, I'm experiencing strange a new behavior in the build process. Probably the changes were triggered when I switched the linker settings in release mode. Although I changed the settings back, I attached the diff of the project file which shows that a build target had been changed from 'Novell.MonoDroid.CSharp.targets' to 'Xamarin.Android.CSharp.targets'.

Now I have and 'Androidobj' build directory in the project root and I cannot build anymore, neither in Debug nor in Release mode.

Is this due to the new Xamarin.Android update recently released?
Comment 10 Tibor Ebner 2015-11-24 08:52:35 UTC
Created attachment 13969 [details]
Android project diff file.
Comment 11 dean.ellis 2015-11-24 09:01:24 UTC
@Tibor

The change of the .targets file is fine. The Novel target was just forwarding to the Xamarin one anyway and is only there for backward compatibility.. the IDE must have upgraded you.

The Androidobj is a weird thing. Can you gist/attach your entire csproj for the project you are having trouble with. Perhaps I can see what the issue is.
Comment 12 Tibor Ebner 2015-11-24 09:06:27 UTC
Dean,

as I surmised, changing back the build target to the original solved the issue. So that forwarding apparently doesn't work as intended. Please find the whole project file attached.
Comment 13 Tibor Ebner 2015-11-24 09:07:29 UTC
Created attachment 13970 [details]
Android project file in its before-the-issue form.
Comment 14 Tibor Ebner 2015-11-27 03:54:28 UTC
Hi Dean,

any progress on the issue? I noticed that Xamarin Studio modified the build targets when I updated Nuget packages. After that point all building attempts fail. The only resort is to revert back to project file to the "old" build targets. And that "Androidobj" directory keeps reappearing :)
Comment 15 dean.ellis 2015-11-27 04:20:14 UTC
Tibor

I can not see anything odd in the csproj that you provided. I will be trying to replicate the issue today.
Does it also happen on a new project? 

Dean
Comment 16 Tibor Ebner 2015-11-27 05:36:33 UTC
@Dean

I tried with the default Xamarin Forms solution and that builds as expected. I also tried to build my project after this successful test build but without success. What's next? I guess "Androidobj" is just for "Android\obj" but somehow the build system cannot resolve that.

Thanks,
Tibor
Comment 17 dean.ellis 2015-11-27 06:11:22 UTC
it seems that the user of %(TargetPath) *might* be causing this issue in certain situations.
Comment 18 dean.ellis 2015-11-27 15:32:11 UTC
@Tibor

I think I might have found a fix. You are welcome to try it locally if you like, but I'd need to know which version of Xamarin.Android you are running.

It looks like there are issues with $(MSBuildProjectDirectory) being used in the .targets were it is not needed in addition to %(TargetPath) 

Dean
Comment 19 Tibor Ebner 2015-11-27 17:32:21 UTC
@Dean

Great news, thanks a lot! All version info is in my first comment with the issue (Xamarin.Android 6.0 etc.). How can I try the fix?

I don't know if it has anything to do with the issue, but I found this in the Refit 2.4.1 Nuget package's build target file (this is one of the packages we use in the project):

<PropertyGroup>
    <IntermediateOutputPath Condition="$(IntermediateOutputPath) == '' Or $(IntermediateOutputPath) == '*Undefined*'">$(MSBuildProjectDirectory)obj\$(Configuration)\</IntermediateOutputPath>    
  </PropertyGroup>
Comment 20 dean.ellis 2015-11-30 11:44:38 UTC
Tibor

That will be where the Androidobj is coming from. The $(MSBuildProjectDirectory) does not include a \ if I remember correctly.In addition the condition is not quite right I don't think. There should be ' around $(IntermediateOutputPath) eg. 

<PropertyGroup>
    <IntermediateOutputPath Condition="'$(IntermediateOutputPath)' == '' Or '$(IntermediateOutputPath)' == '*Undefined*'">$(MSBuildProjectDirectory)\obj\$(Configuration)\</IntermediateOutputPath>    
  </PropertyGroup>

With regards to the other issue. I am attaching a copy of the Xamarin.Android.Common.targets for the latest release. This includes the fix that should get round your issue. Back up your existing file from C:\Program Files (x86)\MSBuild\Xamarin\Android\ and replace it with this one
Comment 21 dean.ellis 2015-11-30 11:45:17 UTC
Created attachment 14028 [details]
Patched Xamarin.Android.Common.targets
Comment 22 dean.ellis 2015-11-30 14:20:21 UTC
Fixed in monodroid/master/853c2a8d
Comment 23 Tibor Ebner 2015-12-04 12:04:32 UTC
@Dean,

thanks for the patch, it works now. What's strange though is that the build still uses the 'Androidobj' folder. Builds succeed but the minute the build targets have been updated by the UI in the Android project file to 'Xamarin.Android.CSharp.targets', an 'Androidobj' folder was created within the project root and the 'sdks.cache' file was put in 'Androidobj\Debug'. Is this the expected behavior or is an issue still lurking there beneath the surface?
Comment 24 dean.ellis 2015-12-04 12:12:39 UTC
@Tibor

as mentioned in comment 20, it looks like the .targets from the Nuget package Refix is redefining the $(IntermediateOutputPath) setting incorrectly so that will be why the Androidobj directory is appearing rather than Android\obj. The Refix project need to fix their target to be

$(MSBuildProjectDirectory)\obj\$(Configuration)\

not 

$(MSBuildProjectDirectory)obj\$(Configuration)\
Comment 25 dean.ellis 2015-12-04 12:13:32 UTC
@Tibor

to be honest they shouldn't be messing about with that setting anyway because it can be changed at the csproj level by the developer.
Comment 26 Tibor Ebner 2015-12-04 12:52:27 UTC
Thank you, @Dean, now I see where the problem lies. I'll make sure this target gets fixed.
Comment 28 Mike 2016-05-28 13:46:08 UTC
Hi guys, Looks like the problem not fixed. I'm using Visual Studio 2015 Update 2 on Windows 10.

Xamarin version is v23.3.0 from Nuget

Whe I set the value to : <BaseIntermediateOutputPath>Y:\NET\Demo\obj\Demo.Droid\</BaseIntermediateOutputPath>

It can't generate the project. visual studio will output:

2>  TradingSystemX.Droid -> Y:\NET\Demo\Debug\Demo.Droid.dll
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1574,3): error MSB4018: “GenerateJavaStubs”任务意外失败。
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1574,3): error MSB4018: System.NotSupportedException: 不支持给定路径的格式。
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1574,3): error MSB4018:    在 System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String fullPath, Boolean checkForDuplicates, Boolean needFullPath)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1574,3): error MSB4018:    在 System.IO.Path.GetFullPath(String path)
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1574,3): error MSB4018:    在 Xamarin.Android.Tasks.GenerateJavaStubs.Run()
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1574,3): error MSB4018:    在 Xamarin.Android.Tasks.GenerateJavaStubs.Execute()
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1574,3): error MSB4018:    在 Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
2>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1574,3): error MSB4018:    在 Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

Note You need to log in before you can comment on or make changes to this bug.