How to include minify files or custom files with web pagckage or MS Deploy package?

Wow it was a large title any way, I suppose now to sit and finishing my proposal of my Mcs and if the Dr read this article she will tell me, What the hell you are doing?? you should finish your proposal but I couldn’t prevent my self from writing this post because it’s very important article to me any way.

If you read most of my articles you will know that I am working on an MVC project and I am using TFS2010 and I automate the whole building process including deployment of database and Test database for Data driven test, running test, deploy database to QA machine and finally create the deploy package and deploy the website to the IIS of the QA machine.

I have some issues, I just doing some workarounds until solve it at a proper time, so now the time come for one of the most important issues which is the minify files didn’t included in the MS deploy package so the deployment of the website didn’t deploy this files

I read a wonderful article to sayed.hashimi, you always impressed me Sayed!!

But it needs a little tweaking to work with minify fiels and I found a question on StackOverFlow which is ”  How can we include the files created by ajaxmin in the msdeploy package created by MSBuild ” so I decide to post an article describe my tweaking to solve this issue.

First you can download the whole project which successfully include the minify file in the MS Deploy package from here Download

First you need to create include for each folder in your application that has minify files and this will has source and destination folder so you make sure you didn’t copy the minify file in every script folder in your application as the following

SolSolution file that show the scripts in your project

Solution file that show the scripts in your project

You need to follow the image or just download the project as mention before

MVCProject file.csproj

MVCProject file.csproj

You can also see the text version here

[sourcecode language=”xml”]

<!– ======== Minify files ========= –>
<Import Project=”$(MSBuildExtensionsPath)MicrosoftMicrosoftAjaxajaxmin.tasks” />
<Target Name=”AfterBuild”>
<JS Include=”***.js” Exclude=”***.min.js;Scripts*.js” />
<CSS Include=”***.css” Exclude=”***.min.css” />
<AjaxMin JsSourceFiles=”@(JS)” JsSourceExtensionPattern=”.js$” JsTargetExtension=”.min.js” CssSourceFiles=”@(CSS)” CssSourceExtensionPattern=”.css$” CssTargetExtension=”.min.css” />

<!– ====== Package the minify fiels ===== –>

<Target Name=”CustomCollectFiles”>
<!– =====Root folder ==== –>
<_CustomFilesForRootFolder Include=”MyScript*.min.js”>
<FilesForPackagingFromProject Include=”%(_CustomFilesForRootFolder.Identity)”>

<!– ======sub folder ==== –>
<_CustomFilesForSubFolder1 Include=”MyScriptLogin*.min.js”>
<FilesForPackagingFromProject Include=”%(_CustomFilesForSubFolder1.Identity)”>

<!– === another sub folder ==== –>
<_CustomFilesForSubFolder2 Include=”MyScriptRegistration*.min.js”>
<FilesForPackagingFromProject Include=”%(_CustomFilesForSubFolder2.Identity)”>



That’s it

Share This: