-
Notifications
You must be signed in to change notification settings - Fork 533
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
Early <AndroidAsset> caching results in differences w.r.t. other platforms, use case limits. #1150
Comments
The use case here, generalized, is the ability to author external packages that provide specialized asset generation/conditioning pipelines for purposes related to package functionality. The cause of the problem appears to be the timing/method of Xamarin.Android's production of an intermediate asset ZIP archive (e.g. obj/Debug/android/bin/packaged_resources). I am assuming this is done to provide a ready-made set of assets to include when APK production ultimately occurs later. The issue, though, is that its acquisition of This results in a difference in behavior under Xamarin.Android vs. other platforms---one that assumes all asset content is static at build start, breaking the use of any MSBuild task-implemented asset production and/or conditioning. |
FWIW 1: The reason true (i.e. not placeholder) asset content in the attached example is done post-compile isn't just for the benefit of demonstrating the problem here. Some pipeline use cases require successful compilation to occur before processing is meaningful---they can't be done earlier, say, in advance of BeforeBuild where Xamarin.Android's implementation would currently pick up the contents. |
FWIW 2: The need to identify and emit placeholders in a before-build preprocess step (as you'll see in the .targets files within the solution/nuget package) is an unrelated appeasement to a subset of the platforms---in addition to Android with |
FWIW 3: If the timing of the generation of packaged_resources cannot be changed, an alternative might be to simply store within it (or alongside it) a manifest of (Storing references vs. copies also has scaling benefits---consider a very asset-heavy application having to endure what look to be unnecessary extra copies.) |
Thanks for the detailed description of the issue. This will require some creative thinking. One of the things that the android process does is create a Zip file which contains all the library resources and assets (layout files etc). This is embedded into the library as part of the compilation process via an EmbeddedResource. Note this is not the There is a reason for this. Nuget and all the google libraries. A library needs to ship as a single assembly with all the required dependencies included. The Embedded Resource is then extracted as part of the app build process into an intermediate directory which is then used for building the app. One option for now might be to do the post processing in the app itself. While we don't have any extension points at the moment you can do
We can add a public I'll have a think about this and see if I can figure out a good way to support this use case. |
Thanks for the quick response, Dean.
I was initially a little confused here, but I follow now after some local playing. What you speak of are Xamarin.Android class library build artifacts (
Tried this just now, and while I will recheck my work it did not appear to change the outcome. The exercise resulted in additional insight, however. Consider the following:
The chain of events (in time order) from the above is consistent with the observed outcome. Specifically (and everything relative to
And for completeness, the contents of (4) above...
... shows the embedded size (34) is in agreement with the placeholder, consistent with the timeline. I seems to me another way to resolve this, with additional performance/storage benefits through elimination of redundancies, might be to simply eliminate your copy of I'll next try, knowing the above, emitting assets directly into the staging folder ( Thanks again! |
Forgot to respond to the tail of your last, Dean:
Can't go into much detail, but we are certainly looking at attributes, etc. and in some cases even performing code analysis to emit build-coordinated data for Useful Purposes™. ;). |
Quick followup on my test, as promised. In the example workspace, if I change a single line in
to:
...I get lucky and see proper from-clean operation. This of course means the placeholders remain, orphaned, in their correct locations and I am injecting the true content instead into Xamarin's asset staging folder, which I really shouldn't be doing. Inelegant, but it might at least unblock us until a better fix is identified. I'll test it more generally (real projects, incremental build changes, etc.). |
another option might be to have your update process emit the updated files directly into I am going to look at changing the build order of |
Thanks for that. I'll give it a shot. |
Context dotnet#1150 The way the current system works is that the `UpdateAndroidAssets` target is called as part of the `ResolveReferencesDependsOn`. This makes it impossible to do any kind of processing of assets after the project has already built. It also menas that a straight up call to `Build` will result in all the assets being copied into the intermediate directory. If your project has a large number of assets that is going to take time. Note this might also be called as part of a designtime build at the moment... not good. So is there a reason why we call `UpdateAndroidAssets` before `Compile`? We don't generate any entries in the Designer.cs files for them.. We don't clean them up.. we dont appear to do anything except package them! So the anser looks to be a resounding NO! So we shall move the `UpdateAndroidAssets` to be part of the `_CreateBaseApkDependsOnTargets`. This means they will be processed just before we create the base apk. This will occur after compilation has completed. So we have a win win.. This commit also includes a unit test which does some post processing after the `Compile` target to update an asset, it makes sure that post processing does work.
PR #1161 should fix this issue. |
Much appreciated, Dean! Thanks for the quick look/resolution. |
Steps to Reproduce
BuildArtifacts.zip
Expected Behavior
In all cases, "This is actual content for asset A." is indicated.
Actual Behavior
For all of { CLI, iOS, UWP }, "This is actual content for asset A." is indicated.
For { Android }, "This is a placeholder for asset A." is indicated.
(Further commentary to follow.)
Version Information
Microsoft Visual Studio Community 2017
Version 15.5.2
VisualStudio.15.Release/15.5.2+27130.2010
Microsoft .NET Framework
Version 4.7.02556
Installed Version: Community
Visual Basic 2017 00369-60000-00001-AA028
Microsoft Visual Basic 2017
Visual C# 2017 00369-60000-00001-AA028
Microsoft Visual C# 2017
Visual C++ 2017 00369-60000-00001-AA028
Microsoft Visual C++ 2017
Visual F# 4.1 00369-60000-00001-AA028
Microsoft Visual F# 4.1
Application Insights Tools for Visual Studio Package 8.10.01106.1
Application Insights Tools for Visual Studio
ASP.NET and Web Tools 2017 15.0.31125.0
ASP.NET and Web Tools 2017
ASP.NET Core Razor Language Services 1.0
Provides languages services for ASP.NET Core Razor.
Azure App Service Tools v3.0.0 15.0.31106.0
Azure App Service Tools v3.0.0
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
JavaScript Language Service 2.0
JavaScript Language Service
JavaScript Project System 2.0
JavaScript Project System
JavaScript UWP Project System 2.0
JavaScript UWP Project System
Merq 1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.
Microsoft Continuous Delivery Tools for Visual Studio 0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards
Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package
Mono Debugging for Visual Studio 4.8.4-pre (3fe64e3)
Support for debugging Mono processes with Visual Studio.
NuGet Package Manager 4.5.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.
SQL Server Data Tools 15.1.61710.120
Microsoft SQL Server Data Tools
TypeScript Tools 15.5.11025.1
TypeScript Tools for Microsoft Visual Studio
Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake
Visual Studio Tools for Universal Windows Apps 15.0.27128.01
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.
VisualStudio.Mac 1.0
Mac Extension for Visual Studio
Xamarin 4.8.0.753 (6575bd113)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 4.8.188 (c5813fa34)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin.Android SDK 8.1.0.25 (HEAD/d8c6e504f)
Xamarin.Android Reference Assemblies and MSBuild support.
Xamarin.iOS and Xamarin.Mac SDK 11.6.1.2 (6857dfc)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Log File
The text was updated successfully, but these errors were encountered: