Setting up Visual Studio to work with Umbraco
Over the last 12 months I have been involved with developing several Umbraco-powered websites. During that time I’ve experienced many development frustrations; specifically with debugging and version control.
A while back I read Paul Sterling’s blog post on “Working with Umbraco in Visual Studio” - I used this as my basis. I have added to his orignal suggestions:
- Have a clean, working copy of Umbraco - using the installer - on your machine. I am using:
C:\inetpub\wwwroot\umbraco\for my working copy of the site. - My Visual Studio solution/project will be kept under version-control. Since I use Subversion, (with TortoiseSVN and VisualSVN), I prefer to keep all my code under:
C:\SVN\ - In the Visual Studio project, I create the following folders:
/_templates/css/scripts/usercontrols/xslt
These folders reflect the files that will be used in my Umbraco site. The “
/_templates” folder is used to store a text-based version of Umbraco templates, so that I can keep them under version-control; as I’ve had a situation in the past where someone copied over the wrong template - not very pretty. - In Visual Studio, create a post-build event [from Project > Properties > Build Events] to copy all your working files across to your Umbraco installation.
XCOPY "$(ProjectDir)bin\$(ProjectName)*.*" "C:\Inetpub\wwwroot\umbraco\bin\" /y XCOPY "$(ProjectDir)usercontrols\*.ascx" "C:\Inetpub\wwwroot\umbraco\usercontrols\" /y XCOPY "$(ProjectDir)xslt\*.xslt" "C:\Inetpub\wwwroot\umbraco\xslt\" /y XCOPY "$(ProjectDir)scripts\*.js" "C:\Inetpub\wwwroot\umbraco\scripts\" /y
You may notice that I am not copying across the
*.cssstylesheet files across to Umbraco. The reason for this is that the current version of Umbraco (v3.0.3) stores the contents of the CSS files in the database, and not on the file-system.You can either set the “Run the post-build event” whichever option you prefer.
- Once your files have been copied across to Umbraco, you can debug your code in Visual Studio:
- Open the site (usually http://localhost/) in your web-browser.
- In Visual Studio select the Debug > Attach to Process menu.
- Select the ASP.NET worker process from the list - this is usually called “
aspnet_wp.exe” or “w3wp.exe” - then press OK.
It’s important to note that I am developing on Visual Studio 2008; but the same prinicple should apply to VS.NET 2005. (Update: It isn’t so straight-forward in VS.NET 2005, see Brad’s comment for further details.)
I’m still looking at ways to improve my development set-up with Umbraco/Visual Studio, so if anyone has any tips - please pass them my way! I’m especially interested in ways of dynamically updating the stylesheets/templates via the Umbraco API.



Like you said, “should apply to VS.NET 2005″ but it does not.
My C# web project in VS.NET 2005 does not have a “Project > Properties > Build Events” option.
I have done some research and it seems I need something called MSBuild which I think is part of “Visual Studio 2005 Web Deployment Projects”.
You can read this Blog about it here..
http://weblogs.asp.net/scottgu/archive/2005/11/06/429723.aspx
I have not yet worked out how to add the simple xcopy commands or anything like them yet but I am working on it. If anyone reading this has done this with VS.NET 2005, please post here how you did it.
Brad
3 Sep 08 at 1:20 am
Ok, I got this sorted for those of you using VS.NET 2005 and have a web project that you want to have build and then copy the files to your Umbraco project.
The stuff I said in my other post is correct. Get the Visual Studio 2005 Web Deployment Projects.
Once you have followed the steps in adding a deployment project to your solution, right click on the deployment project and Open Project File.
In there, look for this xml node.
<Target Name="AfterBuild"></Target>Uncomment it, and add these lines inside it.
Here is the whole thing for completeness.
<Target Name="AfterBuild"><CreateItem Include="$(OutputPath)bin\**\*.dll">
<Output TaskParameter="Include" ItemName="binFiles" />
</CreateItem>
<Copy SourceFiles="@(binFiles)" DestinationFolder="D:\Dev\bin\%(FilesToArchive.RecursiveDir)" ContinueOnError="true" />
<CreateItem Include="$(OutputPath)css\**\*.*">
<Output TaskParameter="Include" ItemName="cssFiles" />
</CreateItem>
<Copy SourceFiles="@(cssFiles)" DestinationFolder="D:\Dev\css\%(FilesToArchive.RecursiveDir)" ContinueOnError="true" />
<CreateItem Include="$(OutputPath)usercontrols\**\*.*">
<Output TaskParameter="Include" ItemName="usercontrolsFiles" />
</CreateItem>
<Copy SourceFiles="@(usercontrolsFiles)" DestinationFolder="D:\Dev\usercontrols\%(FilesToArchive.RecursiveDir)" ContinueOnError="true" />
<CreateItem Include="$(OutputPath)scripts\**\*.*">
<Output TaskParameter="Include" ItemName="scriptsFiles" />
</CreateItem>
<Copy SourceFiles="@(scriptsFiles)" DestinationFolder="D:\Dev\scripts\%(FilesToArchive.RecursiveDir)" ContinueOnError="true" />
</Target>
Now I can get on with the PAYING work.
Brad
3 Sep 08 at 4:28 am