23

I am very much new to the Continous Integration. Could anyone please let me know whether we could build a website using MSbuild?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
user98826
  • 233
  • 1
  • 2
  • 4

4 Answers4

37

You can build a Web Site project using the AspNetCompiler MSBuild task.

http://msdn.microsoft.com/en-us/library/ms164291.aspx

Your MSBuild file might look something like this:

<Project
        xmlns = "http://schemas.microsoft.com/developer/msbuild/2003"
        DefaultTargets = "PrecompileWeb">
        <Target Name = "PrecompileWeb">
                <AspNetCompiler
                        VirtualPath = "DeployTemp" 
                        PhysicalPath = "C:\ccnet\myProject\WebSite"
                        TargetPath = "C:\ccnet\myProject\PreCompiled"
                        Force = "true"
                        Debug = "true"
                        Updateable = "true"/>
        </Target>
</Project>

And then within your ccnet.config, you would add something like the following in the tasks block for your project:

<msbuild>
    <executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
        <workingDirectory>C:\ccnet\myProject\</workingDirectory>
        <projectFile>C:\ccnet\myProject\myproject.msbuild</projectFile>
        <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
Jason Jones
  • 871
  • 5
  • 5
  • This works rather well. I combine this with a couple of tasks that setup the web application in IIS to automate deployments. – Min Apr 30 '09 at 19:31
  • Would you still recommend this approach for a modern, static content website project? – julealgon Feb 12 '18 at 12:35
5

If you have an SLN file for the Web Site, then you can use the following command:

msbuild YourSolutionFile.sln

Toby Artisan
  • 1,639
  • 3
  • 23
  • 26
  • Or, you can just navigate to the directory where the .sln file is and type "msbuild" (assuming msbuild is in the current path). – Andy West Feb 19 '10 at 20:07
3

Yes, you can - even with a "website".

What you need to do is add the "Web Deployment Project" and set it up so it will grab all the files from the website, compile them, and using something like WiX, you can create an installer for the files to be able to easily deploy your web site and all its files needed to a customer's computer.

Marc

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • You can download the web deployment project for Visual Studio 2008 here: http://www.microsoft.com/downloads/details.aspx?familyId=0AA30AE8-C73B-4BDD-BB1B-FE697256C459&displaylang=en for Visual Studio 2005 go here: http://msdn.microsoft.com/en-us/asp.net/aa336619.aspx – lexx May 14 '09 at 11:47
-2

unfortunately, if you have chosen "Website" as the project type you cant. However, if you chose "Web Application" project type, you can use MSBUILD to build it. Once you have created the "web application" project, you can right click on it and select "Add Web Deployment Project" which will add a wdproj file to your solution and you can customize the settings in there.

You can provide this wdproj file to your ccnet config file for the project which can run this as per the schedule configured. i can probably give you teh appropriate nodes required to configure in cc.net config file by tomorrow once i am in the office

Vikram
  • 6,865
  • 9
  • 50
  • 61