-
Notifications
You must be signed in to change notification settings - Fork 685
[Android/Guava] fix for missing [assembly:TargetFramework] #607
Conversation
Fixes: dotnet/android#3343 Context: dotnet/android#3343 (comment) Context: dotnet/android#2934 In Visual Studio 2019 16.1, we added some performance improvements in Xamarin.Android. In cases of .NET assemblies that: * Do not have `[assembly: TargetFramework ("MonoAndroid")]` * Have no reference to `Mono.Android.dll` Unfortunately, these two Guava projects fit into this category! They include `<EmbeddedJar/>` but otherwise have no markings at all that would indicate they are Xamarin.Android assemblies. Reading the source code for MSBuild, I found that including a single `@(Compile)` item solves the issue: https://github.com/microsoft/msbuild/blob/0cd0e92a7243088977d31b56626b56d6116de016/src/Tasks/Microsoft.Common.CurrentVersion.targets#L3341-L3344 <ItemGroup Condition="'@(Compile)' != '' and '$(TargetFrameworkMonikerAssemblyAttributeText)' != ''"> <Compile Include="$(TargetFrameworkMonikerAssemblyAttributesPath)"/> </ItemGroup> As soon as I added an empty `*.cs` file to the projects, `[assembly:TargetFramework]` appeared in the output assembly with the necessary info. This must be a weird corner case for MSBuild... I am not sure if there is anything we can do on the Xamarin.Android side yet.
@Redth is this a NuGet package that would be easy to update? The only possible thing I could do is look for any Also... are there other components like these? |
@jonathanpeppers this might be related to the issue I found dotnet/android#3354 ... |
Would an AssembyInfo.cs file not be better? Surely the assembly should have version information right? |
@dellis1972 yeah I was seeing it put that file in the temp location, but things were working OK. The problem was it doesn't create that file at all if
These are actually SDK-style projects, which don't have |
@jonathanpeppers it might be just adding
or something is enough to get something into the |
This is really weird, if I add those, I get:
These attrributes come from: But the one that is messed up here is: I should probably file an MSBuild bug. |
On second thought, we might be able to just fix this: dotnet/android@master...jonathanpeppers:workmanager It is looking like it only adds ~25ms on every build, but let me time that with a Release build of XA on a slower PC to be sure. |
@jonathanpeppers interesting idea. I would make
support
so that we can extend it in the future. |
Fixes: dotnet/android#3343
Context: dotnet/android#3343 (comment)
Context: dotnet/android#2934
In Visual Studio 2019 16.1, we added some performance improvements in
Xamarin.Android.
In cases of .NET assemblies that:
[assembly: TargetFramework ("MonoAndroid")]
Mono.Android.dll
Unfortunately, these two Guava projects fit into this category! They
include
<EmbeddedJar/>
but otherwise have no markings at all thatwould indicate they are Xamarin.Android assemblies.
Reading the source code for MSBuild, I found that including a single
@(Compile)
item solves the issue:https://github.com/microsoft/msbuild/blob/0cd0e92a7243088977d31b56626b56d6116de016/src/Tasks/Microsoft.Common.CurrentVersion.targets#L3341-L3344
As soon as I added an empty
*.cs
file to the projects,[assembly:TargetFramework]
appeared in the output assembly with thenecessary info.
This must be a weird corner case for MSBuild... I am not sure if there
is anything we can do on the Xamarin.Android side yet.