I'm currently running a CI build and deploy using TFS 2013 for the build and Release Management 2013 for the deployment, though I need the web applications (WebForms) that I'm deploying to be precompiled. I'm looking to use a publish profile to drive the precompilation before the output is copied to the drop location, but I haven't found anything that has been able to do this yet.
After finding How do I configure MSBuild to use a saved publishProfile for WebDeploy? , I set up a publish profile in my web application that will precompile the web application if I use msbuild.exe using the Developer Command Prompt for VS2013
msbuild.exe WebSite.csproj /p:DeployOnBuild=true /p:PublishProfile=TfsPrecompile
Publish Profile named TfsPrecompile, with some help from https://stackoverflow.com/a/13267694/595473
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<ExcludeApp_Data>False</ExcludeApp_Data>
<PublishUrl>$(MSBuildProjectDirectory)\PublishDirectory</PublishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>False</EnableUpdateable>
<DebugSymbols>False</DebugSymbols>
<WDPMergeOption>DonotMerge</WDPMergeOption>
</PropertyGroup>
</Project>
Running MSBuild locally, I end up with the precompiled site in a new PublishDirectory
folder and all seems to have gone well.
To link TFS and Release Management, I'm using the ReleaseTfvcTemplate.12.xaml template.
Build > Projects: $/Insert_Directory_Here/WebSite.csproj
Advanced > MSBuild arguments: /p:DeployOnBuild=true /p:PublishProfile=TfsPrecompile
When I run the build with the MSBuild arguments there are no significant time differences in the nine-or-so minute build when compared to a build without the precompile arguments. When I run MSBuild locally I see references to ASPNETCOMPILER scroll by, though I see no references to ASPNETCOMPILER or aspnet_compiler in any of the TFS diagnostics logs.
It turned out that the build box didn't have all the targets it needed in order to perform the publish, so it just ignored it.
Answer From https://social.msdn.microsoft.com/Forums/vstudio/en-US/c2d10c74-ed44-4635-acb9-ab08612701e2/deployonbuild-not-working?forum=tfsbuild
I believe that there is a bug in the Release templates that affects how web sites are pre-compiled. Look to use the Default Template and instead add the RM bits manually.
http://blogs.msdn.com/b/visualstudioalm/archive/2013/12/09/how-to-modify-the-build-process-template-to-use-the-option-trigger-release-from-build.aspx
First switch to the default template and verify that it does as you want. Then follow the trail above.