How to add a lot of resource files to a monotouch project? - xamarin.ios

I have a lot of png images into a directory. I've added it to the project as Content/Copy if newer. I can load them from the app without problems.
But, the project needs a lot of time to compile. If i make a little change in the code, the project recompiles all again. It takes a lot of time.
I've tried to add another project, add the files to the new project, but then i can not access to the files from the app.
Is there any solution?
Of course, when i debug the app into the iPad, the uploading+install takes a lot of time. These files will not change ever, so...Is there any method to copy all the content ONE time?
Thanks

I just have discovered a tricks. It seems that monotouch does not remove directories when you upload and install from the MonoDevelop environtment, so:
Add your folders and all the files and mark them as Content
Build your project for iPhone/iPad and Run it from MonoDevelop
Remove your data foldres from your porject
Clean the solution
Make any changes you need in your code, your data reamins in the device!!!
That changes all!!! Before that, when i need to make a minor change in my code, i needed to wait about 15' for building and uploading. Now it's just 1 minute!!!

Place your images in a separate class library
Mark all your files as embedded resources
Add a logical name to each resource (in your project file)
<EmbeddedResource Include="Images\Folder\Filename.ext">
<LogicalName>LogicalNameForImage</LogicalName>
</EmbeddedResource>
4. Load the resource as
UIImage.FromResource(yourAssembly, "LogicalNameForImage");
Embedded resources are loaded on demand, not when the assembly loads.

In A future version of MonoDevelop (my patch didn't make it in time for the upcoming 4.0 release), this won't be an issue any longer.
What currently happens in MonoDevelop 3.x is that when building a project, it will only copy the images that have changed into the app bundle, however, after building, MonoDevelop invokes a script that is installed along with Xcode called iphone-optimize which scans the entire app directory and uses pngcrush to crush all of the images (it also converts all plist files into binary plists). This is the step that causes such slow build times if you have a lot of images.
Just after the 4.0 branch closed for QAing, I wrote a patch that avoids the need for invoking the iphone-optimize script. Instead, what MonoDevelop will do is it will directly invoke pngcrush on only the images that have changed, passing the proper app directory location as the output argument to pngcrush so that we avoid an additional file-copy.
From my own testing, this makes a massive improvement to build times for projects with a lot of image files.
In the meantime, what you could do, is make a backup of the iphone-optimize script (should be located somewhere under /Applications/Xcode.app) and then modify it to not crush image files. Then, once you've done that, go and pre-crush all of your png files in your project.
(Note: when the MonoDevelop with my patch finally ships, it'll also have an option to disable calling pngcrush for developers who have already pre-crushed their images).

Related

New developer process for Hybris

I am working on learning Hybris. I have successfully install hybris, there are lots and lots of blogs out there that talk about getting the core hybris install with your own custom moduleds to make changes to, such as this one:
http://javainsimpleway.com/hybris-b2b-installation/
In the blog above the gentleman creates a mystore. The question I have is this: Once you have this all setup, you have made changes to the mystore modules and you want get those changes onto a new developers machine (or productions machine), who do you do it?
What I have tried, which does not work is this:
zipped up the bin/custom/mystore, config/local.properties, and localextensions.xml
followed his steps 1 thru 4
unzipped the files on the new machine
jumped down to step 12 where he does an ant clean all initialize
One difference between his process and mine is that I am adding some addon's. It is my impression that all those changes happen with custom/mystore, but to be safe between my steps 3 & 4 I have rerun the ant addoninstall for all four addon's.
The process I have documented, SmartEdit was not working and I found SAP's documentation about running ant npminstall because Hybris does not include npm-related 3rd party JavaScript libraries. This are blowing up when I go to run ant npminstall.
I really feel like I am trying to recreate the wheel here. I would imagine what I am trying to do is very common to any Hybris team, but I cannot find documentation on how to do it. Does anyone know of a blog out there that talks about how to migrate the source from one machine to another?
there are lots and lots of blogs out there that talk about getting the
core hybris install with your own custom moduleds to make changes to
Although they may be helpful, I would suggest you stick to official Hybris documentation (e.g. https://help.sap.com/viewer/4c33bf189ab9409e84e589295c36d96e/1905/en-US/8acc8a5a86691014a20781b3f738213e.html) which is quite rich.
Once you have this all setup, you have made changes to the mystore
modules and you want get those changes onto a new developers machine
(or productions machine), who do you do it?
For production deployment, please go through https://wiki.hybris.com/display/hybrisALF/Ant+Production+for+Continuous+Integration
However, for simply copying the things from one machine to another machine, whatever artefacts you have already copied to the target machine (after you have installed Hybris on the target machine), are correct. If you are working in a team, you typically set up an SCM (e.g. git, SVN etc.) code repository and then it becomes easier.
It is my impression that all those changes happen with custom/mystore
This is a wrong impression. When you run addon install it creates/updates the project.properties file in the addon; not in your custom/mystore. So, if the addon is part of the code repository (which is typically not the case unless it is a custom addon), anyone pulling your code on their machine will automatically get the addon project.properties and therefore they will not require to run addon install on their machines; otherwise, they need to run addon install on their machines. A workaround is to copy the content of the addon project.properties to the local.properties (and thus getting the changes to the target machine when the local.properties is copied to the target machine).
This are blowing up when I go to run ant npminstall.
Make sure to run ant npminstall as an admin user. Please check https://answers.sap.com/questions/12771768/smart-edit-unable-to-find-local-grunt.html for another option.

What files are required to use NSIS? I am bundling it with another product, so users can create their own installers

I have what might be a simple question and might be....a more complex one. We are preparing to add NSIS to our software, that is, we want people who use our software to be able to create installers using NSIS, but through our software. (We'll be creating functions using NSIS, acknowledging NSIS, etc.) What I am trying to figure out before we get started is how many/what files our customers will be required to have on their hard drive for NSIS to work. So, we just need to know if nsis can be used standalone or if it requires the user to install it into program files, or if it requires a lot of different files in AppData - If we have to bundle a few .dlls, that's not a problem and is expected. Ultimately, if we end up having to bundle NSIS as well, that's fine - We just want to make sure it'll work on other people's computers without telling them to go download it.
MakeNSIS does not read/write from/to the registry or anywhere else and only needs a handful of files for minimal operation.
To build a simple installer you need:
NSIS\MakeNSIS.exe (Just calls Bin\MakeNSIS.exe)
NSIS\Bin\MakeNSIS.exe
NSIS\Stubs\* (If you are only going to use a specific compression mode you only need one, and the uninstaller file if you want uninstall capability)
If you want to use the Modern UI you need its header files, some files from Contrib (Graphics and UI) and system.dll and nsDialogs.dll from the plugin folder.
Everything else is optional but I would recommend that you also bundle:
NSIS\Include
NSIS\Plugins (You can remove stuff you will never need; dialer, splash etc)
NSIS\Contrib (Language files, graphics and UI)
You can find license information here.
You could also just ask the user to install it and enter the path to it in your setup program...
I would just include all of the files. (It's only 5MB or so) NSIS has a zip archive as well as exe installer that includes the necessary files. (Or just zip up the installed directory from exe installer).
From my experience, NSIS does not need to be installed to work. I run a fleet of build servers that build NSIS-based installers, and they each just have the files extracted in a directory. The installer is never run on them. This should mean there are no DLLs to register or things like that.
Just make sure you are following whatever their licensing terms are - I have not reviewed redistribution/bundling of their files in another product, since that is not something I do.

Publish Web App files to different locations

I'm start to develop modules for DotNetNuke. I followed different tutorials(most by Chris Hammond) but there is something i don't like, and I'm searching a different way to do so.
He recommends to put a DotNetNuke installation, with IIS and SQL Server, on the developer PC and put your Project into the DesktopModules folder. I don't like it because i want to separate my project from DotNetNuke.
Is there a way to split the build/publish to different location like dll into folder x and all other stuff into folder y?
You could, but I don't really see the point. I see where you're coming from because it seemed awkward to me at first as well, but it really is the most efficient way to develop on the DNN platform. I have mine set up so all of my modules are in the same solution and branched in source from the root DNN folder. We don't keep the DNN core in source so the developer is responsible for that, although that may change at some point to keep versioning consistent.
By keeping your project located where it's installed, you can develop your modules the same way you'd develop any other web app you're building. If you make a change in markup you just have to save the file and refresh your page. If you change something in code just build and refresh.
If you really must keep them separate, you can absolutely do so (really the only benefit of this that I can see is that if you uninstall a module and accidentally click the checkbox to delete files - it happens - you don't have to worry about it). Create your project where you want it, change the Output Path to your DNN bin folder, and create post-build events to copy all of your .js, .ascx, and .css files (plus any others you may need - images, HTML files, XML files, etc.) to appropriate folder(s) in the DesktopModules folder. Just remember that you have to build the project every time you make ANY changes to test them, and you have to write/change your post-build events every time you add a new type of resource, change/add a directory, etc.
Either that or you can build an install package and uninstall/reinstall the module every time you change some padding in your stylesheet ... but I'd stick with keeping the project in the DesktopModules folder.
Sure you can do that.
Set up your solution and module projects anywhere, build the projects and copy the appropriate parts (such as the *.ascx , *.ascx.resx, *.dnn files) back to your website folder -
website/ DesktopModules/Your_module_name
Copy the module dll to the website's bin and you good to go.

MonoDevelop's Images directory does not seen on XCode(IB)

In my project files marshalling shown below ,Mono Develop doesn't show Images directory(group) in XCode and they are not seen on xib interfaces,also crashes on runtime. But when I put images under Project's root directory works fine!
Fine! But seeing dozens of images on root directory make things confusing.
Here goes details;
My images built actions are content.
I have tried adding them to Xcode by creating a group named Images then this time all images copied to Mono Develop's root again.
Am I missing something?
Project
--Images
---- FaceOff.Png
---- icons
---------CandyButton32x.png
I think you are experiencing a limitation of the XCode integration with MonoDevelop.
Images only show up in XCode if they are in the root directory of your project. To combat this, there are two ways you can setup your image folders for MonoTouch projects:
Use build action Content, put your images anywhere, but they will only show up in XCode if they are in the root of the project
Use the build action BundleResource and put all your images in the Resources folder, this is the same as putting your images in the root of the project, but you get to package them nicely in a subfolder
I have not experimented with BundleResource and XCode to see if subfolders work via that method or not.
This is from my experience, someone from Xamarin, feel free to chime in.
Further to Jonathan's great answer, I have a nice organised setup for my images using BundleResource and the Resources Folder.
On the filesystem I have all my images in a nice directory structure, for example: img/common/title.png.
I then add all the image files (not directories) into the iOS project Resources folder, using the 'Add Files' option and selecting BundleResource for the files I select.
When given the copy, move or link option, because my files are outside the target directory, I select the 'Add a link to the file' option.
This procedure allows me to:
Happily keep all my images in an organised directory structure on the file system
Have access to them in XCode Interface Builder
Access them as root when in code, such as Image.FromFile("title.png")
Easily update them in the filesystem and have them automatically change in Xamarin Studio

Why Does CruiseControl.NET need to be restarted after GetCcNetConfigFiles?

CruiseControl.NET service needs to be restarted to pick up changes in the projects configuration files.
I find this very annoying, not sure if it's a bug or it's the way it works.
Is there any way to overcome this issue in people's experience?
If your projects are separated in a different file from ccnet.config, then you need to restart the service unless you touch the actual ccnet.config.
We use ENTITY with SYSTEM file reference in ccnet.config for our projects, so we're in the same boat. I'm happy to pay the price for easier project maintenance, as it's easy to script a restart:
net stop CCService
net start CCService
IISRESET
If you wanted to completely automate this, and had your projects under source control, then you could trigger an update and restart whenever your project files are touched.
There was a bug in CC.Net prior to 1.4.4 if you were using a pre-processor include it did not reload the configuration when an included ccnet.config file was modified.
That was a bug that I reported and it is fixed in CC.Net 1.4.4 and greater.
Also, keep in mind that if a build is running and there is a change to the configuration it will not take place until that build is in an idle state.
How are you updating your config files? By hand? Mine always recognizes and adjusts. Is your config file in source control and designed to pull it down and replace the file? This for me requires a kick. How I ended up fixing it was have my project pull it down to a seperate folder. THen I call ccnet.exe -validate on it to make sure it is well formed, then I copy it over ontop of the current config file. CC.NET recognizes the changes and loads in the new config
Exceptions: If cc.net is currently running a project, it will not recognize the changes till that project has completed.
If your ccnet.config has errors, it will not ever recognize the changes and keep running the old version it has stored in memory. (However when CC.NET does restart it will try to parse the error filled config and choke.
Hope this helps!!
Do you mean you are using linked files, that is the ccnet.config file has links to the independent project files.
If so then they are not picked up, it's mentioned in the documentation that it doesn't watch the sub-files.
Internally we have modified our CruiseControl.net so that our ccnet.config is optionally a directory - and we can drop shortcuts to our project config files into that directory. We put watches on the directory, the files or shortcuts in the directory and all of the targets of the shortcuts. That means we have our project config files in ClearCase and just drop a shortcut into the ccnet.config directory.
I've just spent half a day or so moving from 1.2 to 1.4.2 dropping our changes into the new version for our internal use. We don't own our code, our client does and so it has to stay internal :(
I have never experienced this. Whenever I change the configuration files, the CruiseControl.NET service seems to automatically re-read them.
I'm using Version 1.3 of CC.NET.
Update:
In the service's config file (ccservice.exe.config), there is a setting to enable/disable watching the ccnet.config file for changes:
<add key="WatchConfigFile" value="true"/>
Make sure this is set to true.

Resources