Theme by nostrich (modified).

06 September 2010 21:51

How to "Publish to filesystem" in msbuild

Despite all the hype around MSDeploy in .NET 4 / VS2010, it doesn't exactly make it easy to do a traditional "Publish to filesystem" from the commandline.

The solution

Thankfully, with this little PowerShell nugget that I found (after much googling and trawling through msbuild target files) you can do just that:

$projectFile = ".\app\MyProject.Web\MyProject.Web.csproj"
$packageTemp
= "C:\output"
$config
= "Release"
# Make sure msbuild is in your PATH
msbuild $projectFile
/t:Package /p:_PackageTempDir=$packageTemp /p:Configuration=$config

This will build your project and run any web.config transforms you've setup. It will then deploy the website files to the $packageTemp directory. Of course if you don't like/use PowerShell it's just a standard msbuild command.

$packageTemp could be your running website, but I tend to deploy it to a temporary directory where I can use a tool like beyond compare to make sure the right changes get to the actual running destination (via FTP).


Tagged: aspnetpowershellmsbuilddeployment

View the discussion thread.blog comments powered byDisqus