Configure IIS on Win 2008 R2 to work with ASP MVC and Web Deploy Video.


In this video I will configure IIS and Web Deployment  on Win 2008 R2 so it can work with ASP MVC application and deployed with Web Deploy by remote administrator

Thanks

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

SolSolution 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


<!-- ======== Minify files ========= -->
 <Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" />
 <Target Name="AfterBuild">
 <ItemGroup>
 <JS Include="**\*.js" Exclude="**\*.min.js;Scripts\*.js" />
 </ItemGroup>
 <ItemGroup>
 <CSS Include="**\*.css" Exclude="**\*.min.css" />
 </ItemGroup>
 <AjaxMin JsSourceFiles="@(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".min.js" CssSourceFiles="@(CSS)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".min.css" />
 </Target>

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

 <PropertyGroup>
 <CopyAllFilesToSingleFolderForPackageDependsOn>
 CustomCollectFiles;
 $(CopyAllFilesToSingleFolderForPackageDependsOn);
 </CopyAllFilesToSingleFolderForPackageDependsOn>
 </PropertyGroup>
 <Target Name="CustomCollectFiles">
 <ItemGroup>
<!-- =====Root folder ==== -->
 <_CustomFilesForRootFolder Include="MyScript\*.min.js">
 <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
 </_CustomFilesForRootFolder>
 <FilesForPackagingFromProject Include="%(_CustomFilesForRootFolder.Identity)">
 <DestinationRelativePath>MyScript\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
 </FilesForPackagingFromProject>

<!-- ======sub folder ==== -->
 <_CustomFilesForSubFolder1 Include="MyScript\Login\*.min.js">
 <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
 </_CustomFilesForSubFolder1>
 <FilesForPackagingFromProject Include="%(_CustomFilesForSubFolder1.Identity)">
 <DestinationRelativePath>MyScript\Login\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
 </FilesForPackagingFromProject>

<!-- === another sub folder ==== -->
 <_CustomFilesForSubFolder2 Include="MyScript\Registration\*.min.js">
 <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
 </_CustomFilesForSubFolder2>
 <FilesForPackagingFromProject Include="%(_CustomFilesForSubFolder2.Identity)">
 <DestinationRelativePath>MyScript\Registration\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
 </FilesForPackagingFromProject>

 </ItemGroup>
 </Target>

That’s it

How to run remote deploy with MS Deploy?



First of all you have to know that in order to install any web application using MS Deploy you mostly need MS Deploy to be installed on the destination machine, so go to the following page and download the MS Deploy click here, install it on the destination machine.

If the destination will be a remote server, you only need to install the remote service on the remote server. In this case, you will use Msdeploy.exe from the local destination computer. The remote service is not required on both machines in such a scenario. For maximum flexibility in synchronization operations, you can install the remote agent service on both the source and destination computers, and verify that the service is started on both computers.

By default the  service is not start so go to the service and start it

Start Service

Start Service

In the local machine start build the application by command line or using the automated with the project properties.

From the visual studio command line write the following

MSbuild MyWebProject.csproj /T:Package /P:Configuration=Debug;PackageLocation="D:\buildfolder\Radwan.zip"

This will produce the following

Web Package

Web Package

Go the MS Deploy from the command line and write a command like the following command:

C:\Program Files\IIS\Microsoft Web Deploy>D:\MVCBuild\MvcTestBuild\MvcTestBuild_20101010.8\_PublishedWebsites\MvcTestBuild_Package\MvcTestBuild.deploy.cmd /T /M:MyServer /u:ServerUserName /p:ServerPassword
Deploy with what if

Deploy with what if?

Remember that the ” T ” meaning “what if” which means test what will happen but not actually deploy.  This will help you to fix any existing issues, if you find everything is OK you can change the T to Y, so you deploy it actually

When you open your destination server you will find that your web application was deployed

Have fun:-)