How To Upload Files to S3 Using MSBuild

Amazon S3 (Amazon Simple Storage Service) is cloud storage solution similiar to dropbox. Instead of storing files on your own web server, S3 has designed to make files sharing quicker, more scalable and easier for developers to share files.

In one of my projectsO had a requirement to copy a number of json files and dll’s from our solution onto our staging enviroment. In order to do this we had to create a build script that copied these files from a folder into a zip and upload that file onto s3. In our build task we had a task to get the zip file form S3 and extract it onto our testing server.

The below snipped should copy all files in a folder called Files and upload them into S3 for you, enjoy 🙂

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="">
<Target Name="Clean">
<RemoveDir Directories="$(S3Files)" />
<MakeDir Directories="$(OutputDir)"/>
<Target Name="UploadFiles">
<CreateItem Include="$(RootDir)\Import\**\*.*">
<Output TaskParameter="Include" ItemName="filesToImport" />
<Copy SourceFiles="@(filesToImport)"
DestinationFiles="@(filesToImport->'$(S3Files)\Import\%(RecursiveDir)%(Filename)%(Extension)')" />
<Target Name="ZipFolder">
<SourceFiles Include="$(S3Files)\**\*.*"/>
<Target Name="UploadToS3" DependsOnTargets="Clean; UploadFiles; ZipFolder;">
Key= "$(key)"
Secret= "$(Secret)"
SourceFiles = "$(S3Files)..\$(S3FileName)"

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

More Posts

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *