I think the question title pretty much said it all, but for clarity, I am trying to:
I've been trying to figure this out for almost a week now, through the Microsoft docs (which are spectacularly unhelpful), other answers on SO and general Googling. I don't know if I'm just not getting it (which is entirely possible), or if MSBuild/MSDeploy really is the cryptic mess it currently appears to be.
Is there a reasonably simple way to achieve this? Help, please!
If you are running VS2010: ensure you have the Azure 1.7+ SDK installed (even if you're not publishing to Azure, it adds the VS2012 publishing features to VS2010)
VS2012+ have these featured built in
msbuild ProjectFile.csproj /p:Configuration=Release ^
/p:Platform=AnyCPU ^
/t:WebPublish ^
/p:WebPublishMethod=FileSystem ^
/p:DeleteExistingFiles=True ^
/p:publishUrl=c:\output
Or if you are building the solution file:
msbuild Solution.sln /p:Configuration=Release ^
/p:DeployOnBuild=True ^
/p:DeployDefaultTarget=WebPublish ^
/p:WebPublishMethod=FileSystem ^
/p:DeleteExistingFiles=True ^
/p:publishUrl=c:\output
Either way, you can also set /p:PrecompileBeforePublish=true
and the output will be a precompiled version of the site.
Once you have the Azure SDK installed you would usually create a publish profile and simply use /p:PublishProfile=DeployToFolder
but I've given you the manual command line in case you're not interested in going all-in with the new publishing stuff.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With