slow-cheetah icon indicating copy to clipboard operation
slow-cheetah copied to clipboard

Transforming an Xamarin Android Asset

Open MihaMarkic opened this issue 7 years ago • 5 comments

Hi guys,

Is it possible to transform an android asset file. Basically it should transform it and put it in the same place (Assets directory or a subdirectory) with the same name.

MihaMarkic avatar Jun 09 '17 11:06 MihaMarkic

If the asset if an XML or JSON file, SlowCheetah should transform it. It will be in the output folder though, not the original folder. I'm not sure if I understood the situation though. Won't putting it in the same place just overwrite the original file?

davilimap avatar Jun 09 '17 18:06 davilimap

"Won't putting it in the same place just overwrite the original file?" I imagine using transformed file for compilation somehow. Or perhaps creating transformed file with different name in the same directory before compilation.

MihaMarkic avatar Jun 09 '17 19:06 MihaMarkic

I'm not too familiar with Xamarin assets, but SlowCheetah outputs files to the output folder. If you need them in a specific folder, you can create a copy task and add it to the project (which can also change the name of the file if that is required). If you need this transformation to occur during a specific time in the build, you can reference the SlowCheetah Build Targets to perform transformations at those times.

davilimap avatar Jun 13 '17 21:06 davilimap

I'm trying to do something similar to this - Xamarin again. I've got an XML file in my PCL project which is an "Embedded Resource" I have code to read from the embedded resource in the PCL project. I have slow cheetah transforms setup on the PCL. I can see that the transformhappens - I see the transformed file in output - but the output transformed file is never "Embedded" in the code that runs on Android or iOS......

I'm assuming that as you specifically allow transforms on files with a build-action of "EmbeddedResource" you also deal with embedding the transformed file instead of the original? In which case, this doesn't seem to work.......Unless there is something else I need to do?

horizondave avatar Jun 16 '17 15:06 horizondave

@horizondave slow cheetah does not enable/disable transforms based on msbuild item type, but rather on the contents of the file. If it is valid JSON or XML it will be enabled regardless of what msbuild item type it is. The slowcheetah targets will perform some project specific actions for well-known files, like app.config. Anything beyond that will require custom build targets provided by you.

As for embedded resource, you will need to investigate what Xamarin does with the embedded resources and add msbuild targets to modify the behavior of the SlowCheetah transforms so that xamarin will work with the transformed file and not the original. You can read about the slow cheetah targets here: targets.md.

jviau avatar Jul 11 '17 23:07 jviau