Custom Build Action similar to AndroidResource - xamarin.android

I am trying to organise an Android project's layout files. Having already worked with MVC, I tried to apply that architectural pattern to the Android project.
Suppose I have a folder structure in my Android project:
Areas > SomeAreaName > Views > details_layout.xml
Setting the Build Action on "details_layout.xml" to AndroidResource results in an "invalid file path" error which is understandable as Android does not allow for files in different locations other than the predefined "res" folder and subfolders.
Is it possible to create a custom Build Action (e.g. AndroidResourceMvc) that can utilise the existing AndroidResource Build Action and with the added ability to appropriately map layout files? If so, how would I go about this?
I've looked at the AndroidResource file and with it being internal and private I don't really have access to it. Neither am I able to just use the raw source code as it imports some namespaces that I also do not have access to (or I just can't seem to find them if they're publicly available).
I'm using Visual Studio 2019 and a Xamarin Android C# project.

Related

Can't access Xilinix SDK 2019.1 application templates

Title explains most of it. When I create a new application project in Xilinx SDK 2019.1 and get to the templates window, the only two available options are 'Empty Application' and 'Opencv Example Application'.
When I look in the /tools/Xilinx/SDK/2019.1/data/embeddedsw directory (which is the default SDK installation repository listed ) I can find many more templates under lib/sw_apps. Directories such as hello_world, and in particular zynq_fsbl which I am looking to use, are in there.
I would like to know how I can actually use these templates and why they are not showing up when creating a new application project.
Apparently the Target Software language of the application project must be C to access these templates. I was trying to use C++.

When publishing, what is exactly supposed to be published?

I'm not used with "publishing" a project via visual studio. I'm trying to do so since yesterday and I've found out these things:
All the images contained in my application in a specific folder (example: MyProject/Images/Image1.jpeg) are only copied the same way they are in my project;
None of my controllers/utility class appears in the published project;
However the views are presents and the javascript files as well, but as they are, so a MyApp.js will be copied as a MyApp.js.
So my question is: is it supposed to be that way? What about my logic, ain't it not supposed to be copied as well? And shouldn't it be compressed, compiled, or protected in a dll, else everyone will be able to see my code in public, which I do not want?
Feel free to teach me what's a publish is supposed to do and what went wrong. thanks!
Publish is supposed to do almost what you mentioned only..
Images in content folder
any stylesheets in the content folder
Scripts in script folder
All View files Anything with Build Action = Content
The compiled files form the dll of your binary & dependencies
Infact all the images, css, javascripts will also have buildaction set to content only.
If you have a file selected in the project and it is not found in the folder, if its build action is "content", the build will succeed but the publish may fail. So in this case you may have to exclude the file if it is not necessary or add the file in the folder
Most of the automatic build systems like cruise control also do the same though with quite an advanced interface.
Your logic in c# or vb.net is already compiled into the binaries. But any script or styles or scripts inside html won't be protected. But bundling the scripts and styles using the BundleConfig may protect it to some extent.
All Your logic is converted into dll's so just create an instance on IIS and host your application there. You can follow the steps shown here.

Why does this project appear to have links to files in another project?

This is the TaskyPro solution, available here: https://github.com/xamarin/mobile-samples/tree/master/TaskyPro/
If you look at the solution structure on GitHub it doesn't have anything odd about it, but when I load the solution in Visual Studio it appears as follows:
The Tasky.Android project contains the same folders as the Tasky.Core project, and it appears to have links to the files in Tasky.Core. However, when I view the folders in Windows Explorer they are empty. If I view the properties of the links, the Full Path property points to the actual file stored in the Tasky.Core project.
Why are these links here? Can I remove them?
File linking is a way to share the same files across multiple projects without having to maintain multiple copies of each file by hand. In this case, it allows you to compile the same source files for both .NET and Android. Xamarin has a lot of documentation on this, including this article which describes how Tasky is architected and implemented. I also recommend reading this guide on Sharing Code Options.

How to use common Layout and styles across multiple Asp.net MVC applications

I have a visual studio solution with multiple telerik MVC4 razor projects having same look and feel. I don't want to have same layout, CSS/styles, images and js files copied in all MVC4 projects. What is the best way to accomplish this re-usability? I tried creating a virtual directory of a commonUI project and tried to refer _layout.cshtml using http://localhost/... in _ViewStart.cshtml but it complained saying "http:/localhost/MyMvcApp/Views/Shared/_Layout.cshtml' is not a valid virtual path."
Please help!
Four recommendations:
1) Look into areas, maybe instead of having separate projects these are really different components of the same system (admin, etc.)?
2) Use add existing item in visual studio and add the items via links. This still duplicates them for deployment, but you can keep one source.
3) Consider doing this by building your own nuget package. That way although you would copy the CSS and images you would have it packaged up and could update the package as needed. The benefit is that you can update one project while not having to re-test the other (if they are separate and 1) doesn't apply).
4) I find this one uglier than the rest, but in IIS I believe you can map in folders, so you could refer to these files by links in your project, not deploy them there and then map in the appropriate folder at deployment time using a single source path.
I know of no way to share up the application path.
EDIT:
I have never tried this before, so can't vouch for it working, but maybe compile your shared items in a separate project and then reference the DLL in all other projects.
The reference I found is this, but again, I haven't confirmed that this works, just think this could be a viable path to explore:
http://www.chrisvandesteeg.nl/2010/11/22/embedding-pre-compiled-razor-views-in-your-dll/
Areas are bad because you cannot deploy them separately. Like you, I tried using virtual directories, and was successful referring to the layouts using relative syntax:
#{
Layout = "~/Common/Layouts/Layout-001.cshtml";
}
Above, the project's layout inherits the layout in the /common/ virtual directory at the root. As the common layout (along with it's bootstrap & jquery versions) evolve, you can use side-by-side version-named physical folders (like common.v01, common.v02,). So you can upgrade your applications to a newer common layout by changing the VD's path to the appropriate version.
The downside with this is you'll need to use IIS (not express) as your dev and test platform.

ASP.NET MVC: How can I add views, scripts and content files as links in order to share across projects? (Via "Add as Link" in VS)

I've got a common Layout.cshtml file that I want to share. When I add the file as a link in the project (via Add Existing Item > Add as Link) I get an error that it cannot be found when I run the application. If I set the build action to "Copy Always" it does copy the file to the build directory, however I still get an error that it cannot find the file (Perhaps I can somehow instruct VS to copy it to the appropriate directory?).
I came across this question: ASP.NET 2 projects to share same files however the answers are pretty complicated and ugly and right now I'm playing around with a lot of different structures and refactoring methods so I don't want to go through some big production just to move a few different files around.
So how can I easily share these kinds of files between the two applications?
Thanks!
You cannot Add as Link static files in an ASP.NET web application. All files need to be included inside this application or when you deploy it in IIS simply won't be able to find any of them. A common technique of sharing static files between multiple web applications is using CDN (Content Delivery Network) where you would host all your static resources (images, CSS, js, ...). For example Google already provides popular frameworks on their CDN.
So for all your custom images you could setup a domain on your web server which will host them all and your web applications will point to this common location. Another advantage of this technique is that clients visiting those applications will already have all static resources in cache.
Looks like it's a bug in msbuild or an unsupported feature. Either way I finally found a workaround published on this guy's blog:
http://consultingblogs.emc.com/jamesdawson/archive/2008/06/03/using-linked-files-with-web-application-projects.aspx
Someone else might give you a better solution, but my approach would be to:
1 - Create a library project
2 - Create a Resources file in the library project
3 - Add the shared resources to the library project.
4 - Compile the library project
5 - Reference the DLL for the library project in the dependent projects

Resources