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?](https://stackoverflow.com/questions/4890289/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.