How to download files from AWS S3 via CodeBuild - c#

I have a build in AWS who get an Automation Project from GitHub and runs it. All the files that we are using to upload to the UI are currently saved to the repo of the project. I don't like it as it is about 300 - 400 MB, and that is a lot. My idea is to use the CodeBuild Buildspec and download the files from AWS S3 to the server before the broject is build. Is this possible at all?
I am new the the CodeBuild so I prefer some guidance. If the whole idea is not possible, I will have to use the project SetUp but there are a lot of things that can break while trying to download the files.

There are multiple ways to do this, but in general you have to generate a buildspec.yaml that instructs AWS CodeBuild to do what you want.
The AWS Documentation is actually pretty good, there are a lot of examples.
This one downloads the source primiarily from S3 and secondary sources from Github. This might fit your use case.
Have a look at the other examples as well, they might help generating the buildspec.yaml
If none fits, you will still be able to run normal bash commands and do aws s3 sync or something similar.

Related

Best practice to send a ASP.Net Core Web App project to someone?

I'm a newbie in ASP.NET projects and I am wondering how do I share my finished C# project to someone by email so they can run it (IIS Express) on their machine ? It's for a job offer skill test.
Do I need to send every files and folders or i can just send the source code?
The project folder is 6MB so i can't send it by email.
Sorry for my English and thanks for help !
A nice way to send it could be by uploading it to GitHub and sharing the repository link. Since it is for a job it will also showcase that you are Version Control savvy.
You can also include a README.md file there that describes the app.
I'm not sure this has anything to do with ASP.net. It's just a question on how to transfer a large file isn't it? If so, 6mb isn't really that large for email nowadays. Most mail servers will handle that fine. But if email is a problem, put it on one of the myriad of fileshare platforms available such as Dropbox.
As for what specific files you need to send. That would depend on the requirements the company gave you - but I'd imagine they certainly need to see your source code and likely want the entire thing to be runnable. So send whatever is needed so they can easily run it.
Have you tried zipping it up? Source code will generally zip very effectively to a much smaller file as it contains so much repetition.
Upload the zip file to your google drive and then send it as a drive attachment. (This is actually Google’s recommendation) Or just simply share it with them. I recommend that attachment be as small as possible in the event that the user your sending it to has a mail quota.

ASP.net Create a Torrent from File

Our current software updates are hosted on our server.
We'd like to offer Torrents as an alternative download option from our server. When new releases are published it should offer people better download speeds if people seed it.
I've figured out everything except how to create a Torrent file automatically (we'd rather not have to create it manually each time).
Does anyone know how we can create a torrent file from a specified exe file?
Thanks!
MonoTorrent seems like it might be of help. I've previously compiled and run it under .net, so no worries there.
This looks like the relevant wiki page.
As usual, it's probably best to check license compatibility before integrating with your product, but it looks quite permissive.
Of course, you'll need to host the torrent to ensure at least a single seed!

How can I deploy static content separately from my Azure solution?

I saw the following comment on Stack Overflow but I'm unable to find a reference to it.
"Yes it is. I have seen a Azure webcast from Cloud9 where the application was
broken up. The static content like images, html, css etc were deployed separately
than the Azure solution. The azure web app just linked to these resources"
Has anyone done this and have any information on how to do it?
As #Joe gennari mentioned: image links, css links, etc. just need to be changed, to reference objects in blob storage. For instance: <img src="http://mystorage.blob.core.windows.net/images/logo.jpg" />.
To actually get content into blob storage, you can:
Create a little uploader app, making very simple calls to via one of the language SDKs (Java, php, .net, python, etc.).
Upload blobs using PowerShell cmdlets - see command documentation here.
Use a tool such as Cerebrata's Cloud Storage Studio or Clumsy Leaf CloudXplorer, which lets you work with blobs in a similar way you'd work with your local file system.
You would no longer be bundling static content with your Windows Azure project. You'd upload blob updates separately (and without need for re-uploading an Azure project). This has the benefit of reducing deployment package size.

How to run external executables from an Appharbor application (HTML to PDF generation)?

I have a requirement to produce PDF's for one my .Net web applications currently hosted on Appharbor.
Traditionally, I would simply install latex on the machine, and create PDF's on the fly with pdflatex. This requirement is to display sections in HTML to end users, but also have a downloadable PDF - so it's slightly different.
I have found several (free) external HTML to PDF converters which may be applicable in this instance. However, I haven't found any libraries allowing me to do this purely programatically.
What advice would you give if I plan to continue using Appharbor?
Should I set up a seperate EC2 (or similar) instance to run such an application from? Or is there a better alternative?
I'd recommend using something like DocRaptor. Note that you can probably continue with your current scheme if you place the relevant pdflatex executable (and it doesn't require the entire Latex runtime) alongside the code you push to AppHarbor. AppHarbor will also be introducing background workers, which might be a good fit for this sort of work.
Note that if you're trying to use Rotativa or using wkhtmltopdf with routes obtained from HttpContext you'll need to use this workaround:
http://support.appharbor.com/kb/getting-started/workaround-for-generating-absolute-urls-without-port-number
or install the premotion fix from Nuget:
https://github.com/trilobyte/Premotion-AspNet-AppHarbor-Integration

Minifying and combining files in .net

I am looking at implementing some performance optimization around my javascript/css. In particular looking to achieve the minification and combining of such. I am developing in .net/c# web applications.
I have a couple of options and looking for feedback on each:
First one is this clever tool I came across Chirpy which via visual studio combines, minifies etc -> http://chirpy.codeplex.com/ This is a visual studio add in but as I am in a team environment, this tool isnt ideal.
My next option is to use an Msbuild task (http://yuicompressor.codeplex.com/) to minify the files and also combine them (maybe read from an xml file what needs to be combined). While this works for minifying fine, the concern I have is that I will have to maintain what must be combined which could be a headache.
3rd option is to use msbuild task just for the minifying and at runtime using some helper classes, combine the files on a per page basis. This would combine the files, give it a name and add a version to it.
Any other options I could consider? My concern with the last option is that it may have performance issues as I would have to open the file from the local drive, read its contents and then combine the files. This is alot of processing at run time. I was looking at something like Squishit - https://github.com/jetheredge/SquishIt/downloads This minifies the files at run time but I would look at doing this at compile time.
So any feedback on my approaches would be great? If the 3rd option would not cause performance issues, I am leading towards it.
We have done something similar with several ASP.NET web applications. Specifically, we use the Yahoo Yui compressor, which has a .NET library version which you can reference in your applications.
The approach we took was to generate the necessary merged/minified files at runtime. We wrapped all this logic up into an ASP.NET control, but that isn't necessary depending on your project.
The first time a request is made for a page, we process through the list of included JS and CSS files. In a separate thread (so the original request returns without delay) we then merged the included files together (1 for JS, 1 for CSS), and then apply the Yui compressor.
The result is then written to disk for fast reference in the future
On subsequent requests, the page first looks for the minified versions. If found, it just serves those up. If not, it goes through the process again.
As some icing to the cake:
For debug purposes, if the query string ?debug=true is present, the merged/minified resources are ignored and the original individual files are served instead (since it can be hard to debug optimized JS)
We have found this process to work exceptionally well. We built it into a library so all our ASP.NET sites can take advantage. The post-build scripts can get complicated if each page has different dependencies, but the run-time can determine this quite easily. And, if someone needs to make a quick fix to a CSS file, they can do so, delete the merged versions of the file, and the process will automatically start over without need to do post-build processing with MSBuild or NAnt.
RequestReduce provides a really nice solution for combining and minifying javascript and css at run time. It will also attempt to sprite your background images. It caches the processed files and serves them using custom ETags and far future headers. RequestReduce uses a response filter to transform the content so no code or configuration is needed for basic functionality. It can be configured to work in a web farm environment and sync content accross several servers and can be configured to point to a CDN. It can be downloaded at http://www.RequestReduce.com or from Visual Studio via Nuget. The source is available at https://github.com/mwrock/RequestReduce.
have you heard of Combres ?
go to : http://combres.codeplex.com and check it out
it minifies your CSS and JS files at Runtime meaning you can change any file and upload it and each request the client does it minifies it.
all you gotta do is add the files u wanna compress to a list in the combres XML file and just call the list from your page / masterpage.
if you are using VS2010 you can easily install it on your project using NuGet
here's the Combres NuGet link: http://combres.codeplex.com/wikipage?title=5-Minute%20Quick%20Start
I did a really nice solution to this a couple of years back but I don't have the source left. The solution was for webforms but it should work fine to port it to MVC. I'll give it a try to explain what I did in some simple step. First we need to register the scripts and we wrote a special controller that did just that. When the controller was rendered it did three things:
Minimize all the files, I think we used the YUI compression
Combine all the files and store as string
Calculate a hash for the string of the combined files and use that as a virtual filename. You store the string of combined files in a cached dictionary on the server with the hash value as key, the html that is rendered needs to point to a special folder where the "scripts" are located.
The next step is to implement a special HttpHandler that handles request for files in the special folder. When a request is made to that special folder you make a lookup in the cached dictionary and returns the string bascially.
One really nice feature of this is that the returned script is always valid so the user will never have to ask you for an update of the script. The reason for that is when you make a change to any of the script files the hash value will change and the client will ask for a new script.
You can use this for css-files as well with no problems. I remebered making it configurable so you could turn off combine files, minimize files, or just exclude one file from the process if you wanted to do some debugging.
I might have missed some details, but it wasn't that hard to implement and it turned out very well.
Update: I've implemented a solution for MVC and released it on nuget and have the source up on github.
Microsoft’s Ajax minifier is suprisingly good as a minification tool. I wrote a blog post on combining files and using their minifier in a javascript and stylesheet handler:
http://www.markistaylor.com/javascript-concatenating-and-minifying/
It's worthwhile combining the files at run time to avoid having to synchronise new versions. However, once they are programmatically combined, cache them to disk. Then the code which runs each time the files are fetched need only check that the files haven't changed before serving the cached version.
If they have changed, then the compression code can run as a one-off.
Whilst there will be a slight performance cost, you will also receive a performance benefit from fewer file requests.
This is the approach that the Minify tool uses to compress JS/CSS, which has worked really well for me. It's Linux/PHP only, but you might get some more ideas there too.
I needed a solution for combining/minifying CSS/JS on a .NET 2.0 web app and SquishIt and other tools I found weren't .NET 2.0-compatible, I created my own solution that uses a syntax similar to SquishIt but is compatible with .NET 2.0. Since I thought other people might find it useful I put it up on Github. You can find it here: https://github.com/AlliterativeAlice/simpleyui

Categories

Resources