Precompile ASP.net website as part of build
The ability to precompile an ASP.net website in Octopack or as part of the build to allow deployments to be shorter for multiple environments.
Please see the source for much more detail!
Source: http://help.octopusdeploy.com/discussions/questions/887

We think that precompilation is best done at compile time, however have been hesitant to it into OctoPack as there are many options to the pre-compilation. Keeping it as a msbuild separate step that is run before OctoPack keeps things flexible.
In light of @Loránd’s project (thank you) and the alternative instructions @David shared, we think that adding this functionality to OctoPack would not add any value.
-
Wayne Brantley commented
As we move toward .net core, the command line .net build has a precompile option.
-
RS commented
Anyone saying that this shouldn't be part of Octopus Deploy: you're correct. It should, however, be part of OctoPACK. OctoPack comes _before_ deployment; it's the final stage of the build process.
LorandBiro's OctoPack.Precompile worked flawlessly for me. Thanks!
-
Loránd Biró commented
In case someone looking for a simple solution I created a NuGet package (OctoPack.Precompile) that adds an ASP.NET precompile step to the build just before OctoPack is called. You can add precompilation to projects only by installing the package:
-
Steven commented
Precompilation should not be a deployment step. Instead, it should happen after the build but before packaging the web application. This step is a trivial task in MSBuild (literally): the AspNetCompiler task.
https://msdn.microsoft.com/en-us/library/ms164291.aspx
Please change OctoPack to call this task, redirect the outputs to somewhere in the obj\ folder and then run OctoPack on that folder instead of the project root.
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" TargetPath="$(IntermediateOutputPath)OctoPackTmp"/>
-
Wayne Brantley commented
@Austin - it will package it up. Your publish profile should publish it to a deploy folder relative to the project. Then octopack will pack that up.
-
Austin Thackston commented
@Wayne I precompiled directly to the drops folder using this method when using TFS and Release Management. The problem is Octopack will not package up my deployed website using the method you just mentioned.
Or at least I can't get it to.
-
David Keaveny commented
This process works for me : http://chriseelmaa.com/octopus-deploy-precompile-asp-net-application/, which I found at http://help.octopusdeploy.com/discussions/questions/887
-
Wayne Brantley commented
@nick, actually I think I understand exactly what you are saying. We do exactly what you want to do.
I deploy a fully precompiled asp.net website. In fact, under MVC, we don't even deploy all our view source as those are precompiled.
Here is how you do it.
1) Create a publish profile in Visual Studio - configure the options in that publish profile to precompile. Name it CI. That will create a CI.pubxml file in your solution.2) Add 'MSBuild' step after the 'visual studio' build step.
3) Configure the msbuild step to do what the publish profile setup by adding command line parameters. Here is what mine looks like:
/p:DeployOnBuild=true /p:PublishProfile=CI.pubxml /p:VisualStudioVersion=12.0 /p:Configuration=Release
-
Nick Nau commented
@Wayne Brantley/@Nick Lechnowskyj I think that you are missing the point of the request. What is being requested is not the initial code compilation (which should be done on a seperate build server), but rather the application pre-compilation that happens on the web server once the code is requested by a user from within IIS. This process is handled by aspnet_compiler as compared to the msbuild that I believe you both are thinking this refers to. The intent is to deploy code that will not suffer from a long delay for the "lucky first customer."
-
darrell tunnell commented
Please add this feature to OctoPack..
-
nkwinder commented
@Wayne Brantley you say that "In TeamCity you can easily do a precompile during the build process and put the precompiled code into a package. Then simply have octopus deploy use that package"
I haven't found a simple solution for that! Why not have an octopus step to do that for you in teamcity? Or else, i would have to provide a custom msbuild script, then custom nuspec? etc Not clean at all.
-
Wayne Brantley commented
@nkwinder - I do not believe this should or will be built in. Your build servers should be doing this step for you.
-
nkwinder commented
Any update on this one?
-
Francis Spor commented
I actually agree that this shouldn't be a feature in octopus proper, but should be a flag on octopack. Octopus is just the deployer in my mind, but octopack, in preparing the nuget package for deployment should have the knowledge to preprocess, if the user wanted.
-
Nick Lechnowskyj commented
I'm not sure how this fits into Octopus Deploy. This is a feature meant for a build tool not a deployment tool such as Octopus. Please focus on making Octopus better at what is was meant to do.
-
Wayne Brantley commented
This feature does not belong in Octopus.
You would have to deploy all the source, views, etc to your servers.
You would then have to call the precompile executable (and merge likely) and have that run on your server. This can be an intensive process and will 100% cpu for several minutes. (This may fail due to compilation issues) This needs to happen on every machine you deploy to. Why not just do it up front?What I do is to use TeamCity. In TeamCity you can easily do a precompile during the build process and put the precompiled code into a package. Then simply have octopus deploy use that package.
-
Shawn Shelton commented
Please add this feature