Skip to content
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

.Net "standard" library referenced by an Android project fail after conversion from nuget -> paket #2800

Closed
7sharp9 opened this issue Sep 28, 2017 · 23 comments

Comments

@7sharp9
Copy link
Member

7sharp9 commented Sep 28, 2017

Description

I have a .Net "standard" library referenced by a Android project, when the projects are converted to a paket solution I encounter a build failure.

Repro steps

I have a before paket conversion at https://github.com/7sharp9/androidTest and a paket branch https://github.com/7sharp9/androidTest/tree/paket after the conversion available. The nuget version build fine.

git clone https://github.com/7sharp9/androidTest -b paket
cd androidTest
dotnet build netstandardLib/netstandardLib.fsproj
msbuild androidTest/androidTest.fsproj

Expected behavior

Build works

Actual behavior

build fails with:

Build FAILED.

"/Users/dave.thomas/Projects/androidTest/androidTest/androidTest.fsproj" (default target) (1) ->
(_ResolveAssemblies target) ->
  /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1445,2): error : Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Microsoft.Identity.Client, Version=1.1.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'. Perhaps it doesn't exist in the Mono for Android profile? [/Users/dave.thomas/Projects/androidTest/androidTest/androidTest.fsproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1445,2): error : File name: 'Microsoft.Identity.Client.dll' [/Users/dave.thomas/Projects/androidTest/androidTest/androidTest.fsproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1445,2): error :   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x00124] in <6a0245f99c1849bf83cb02ca9f84914e>:0  [/Users/dave.thomas/Projects/androidTest/androidTest/androidTest.fsproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1445,2): error :   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00000] in <6a0245f99c1849bf83cb02ca9f84914e>:0  [/Users/dave.thomas/Projects/androidTest/androidTest/androidTest.fsproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1445,2): error :   at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver, System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x0015c] in <52b04bb21b54415ab282c60622b3bc28>:0  [/Users/dave.thomas/Projects/androidTest/androidTest/androidTest.fsproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1445,2): error :   at Xamarin.Android.Tasks.ResolveAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver) [0x0019c] in <52b04bb21b54415ab282c60622b3bc28>:0  [/Users/dave.thomas/Projects/androidTest/androidTest/androidTest.fsproj]
@7sharp9
Copy link
Member Author

7sharp9 commented Sep 28, 2017

detailed msbuild log available here: https://gist.github.com/7sharp9/e0bcee9fcaad3601c3dee702bb5c4b54

@forki
Copy link
Member

forki commented Sep 28, 2017

  1. you didn't gitignore the paket-files folder. The cache file is commited. so subsequent restores think everything is already in place

@forki
Copy link
Member

forki commented Sep 28, 2017

(@matthid we should make convert somehow gitignore it!?)

@forki
Copy link
Member

forki commented Sep 28, 2017

FileNotFoundException should be gone after nuking of paket-files folder and "paket restore"

@7sharp9
Copy link
Member Author

7sharp9 commented Sep 28, 2017

After nuking that folder and paket restore its still the same

@forki
Copy link
Member

forki commented Sep 28, 2017

are you sure it's exactly the same message? because now the packages folder should exist

@7sharp9
Copy link
Member Author

7sharp9 commented Sep 28, 2017

"/Users/dave.thomas/Projects/androidTest/androidTest/androidTest.fsproj" (default target) (1) ->
(_ResolveAssemblies target) ->
  /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1445,2): error : Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Microsoft.Identity.Client, Version=1.1.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'. Perhaps it doesn't exist in the Mono for Android profile? [/Users/dave.thomas/Projects/androidTest/androidTest/androidTest.fsproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1445,2): error : File name: 'Microsoft.Identity.Client.dll' [/Users/dave.thomas/Projects/androidTest/androidTest/androidTest.fsproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1445,2): error :   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x00124] in <6a0245f99c1849bf83cb02ca9f84914e>:0  [/Users/dave.thomas/Projects/androidTest/androidTest/androidTest.fsproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1445,2): error :   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00000] in <6a0245f99c1849bf83cb02ca9f84914e>:0  [/Users/dave.thomas/Projects/androidTest/androidTest/androidTest.fsproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1445,2): error :   at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver, System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x0015c] in <52b04bb21b54415ab282c60622b3bc28>:0  [/Users/dave.thomas/Projects/androidTest/androidTest/androidTest.fsproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1445,2): error :   at Xamarin.Android.Tasks.ResolveAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver) [0x0019c] in <52b04bb21b54415ab282c60622b3bc28>:0  [/Users/dave.thomas/Projects/androidTest/androidTest/androidTest.fsproj]

@forki
Copy link
Member

forki commented Sep 28, 2017

TBH I have no idea what is happening. Do you see what is wrong in the fsproj?

@forki
Copy link
Member

forki commented Sep 28, 2017

also it's weird that's importing NETStandard.Library.targets

why are you mixing old and new proj formats?

@7sharp9
Copy link
Member Author

7sharp9 commented Sep 28, 2017

Its just a new droid template from vs4mac, I can't tell whats wrong to be honest, I spent a good few hours yesterday trying to figure out whats going on then decided to file this small repo.

@forki
Copy link
Member

forki commented Sep 28, 2017

it is so weird. but will try to dig deeper

@forki
Copy link
Member

forki commented Sep 28, 2017

one thing that is not ok is: you did not set TargetFrameworkIdentifier

@forki
Copy link
Member

forki commented Sep 28, 2017

and it looks like your TargetFrameworkVersion is 8 - which don't know yet in paket

@forki
Copy link
Member

forki commented Sep 28, 2017

let's try something:

<When Condition="$(TargetFrameworkIdentifier) == 'MonoAndroid' And ($(TargetFrameworkVersion) == 'v7.0' Or $(TargetFrameworkVersion) == 'v7.1')">
  <ItemGroup>
    <Reference Include="Microsoft.Identity.Client">
      <HintPath>..\packages\Microsoft.Identity.Client\lib\monoandroid70\Microsoft.Identity.Client.dll</HintPath>
      <Private>True</Private>
      <Paket>True</Paket>
    </Reference>
  </ItemGroup>
</When>

please set targetframework to MonoAndroid and manually add the 8.0 in that condition.

would that help?

@matthid
Copy link
Member

matthid commented Sep 28, 2017

(@matthid we should make convert somehow gitignore it!?)

We could move it to the .paket folder or somewhere where stuff is gitignored anyway?

@forki
Copy link
Member

forki commented Sep 28, 2017

.paket is not gitignored everywhere

@7sharp9
Copy link
Member Author

7sharp9 commented Sep 28, 2017

Xamarin abuse the TargetFrameworkVersion to represent the Android version, 8 is the latest one. I can drop it to 7.1

@forki
Copy link
Member

forki commented Sep 28, 2017

still you need to set MonoAndroid to activate the case

@7sharp9
Copy link
Member Author

7sharp9 commented Sep 28, 2017

note: this was the out of the box template for droid I didn't add or remove anything

@7sharp9
Copy link
Member Author

7sharp9 commented Sep 28, 2017

TargetFrameworkIdentifier along with TargetFrameworkVersion dropped to 7.1 is making things build, hard to decipher the errors in msbuild, especially as they look to be coming form Mono.Cecil

@forki
Copy link
Member

forki commented Sep 28, 2017

ok. good. so we need to add the 8.o to our moniker collection. will do tomorrow.

@forki
Copy link
Member

forki commented Sep 29, 2017

image

@forki
Copy link
Member

forki commented Sep 29, 2017

5.100.3 will add this automatically. You still need to set TargetFrameworkIdentifier

@forki forki closed this as completed in cdcc2e1 Sep 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants