user1269016
user1269016

Reputation:

Cannot deploy website using "Precompile during publishing" option

I am trying to publish my web app.

Here is a picture of my setting for my publishing profile: enter image description here

As you can see, I have the "Precompile during publishing" option checked.

Here is the Configuration settings for "Precompile during publish". enter image description here

When this is checked, and I try and publish my web app, I get an error on one of my pages. When I hover over the tab to see the file location, the location is at: C:\Users\akemp.WT\AppData\Local\Temp\WebSitePublish... This is not the location of my source code, and if I make the changes on my local page, the site in the above given path does not get updated.

When I unchecked the "Precompile during publishing" option, my website published without any hassle.

What is going on here?

Upvotes: 3

Views: 5182

Answers (2)

user1269016
user1269016

Reputation:

When I tried publishing with the "Precompile during publishing" option checked, I got an error on one of my code behind files.

When I made changes to my code behind file in visual studio, saved and rebuild my solution, and then tried to publish, the issue would still exist. When I double clicked on the error in the Error list, it opened my page's code behind file, except for the fact that it was the file located at "C:\Users\akemp.WT\AppData\Local\Temp\WebSitePublish...\RandomPage.aspx.cs", and not located at my source folder.

After I individually published that page on it's own (Right click on RandomPage.aspx.cs, and select Publish RandomPage.aspx.cs), I was able to publish my web app with the "Precompile during publishing" option checked.

Upvotes: 1

Oguz Ozgul
Oguz Ozgul

Reputation: 7187

Pre-compilation means all your source code (including aspx.cs files for web site projects, class files under app_code folder, resx files, the global.asax file, and even the aspx files - unless "Allow precompiled site to be updatable" is selected) are combined and compiled into assemblies.

global.asax will have it's own assembly, app_code will have it's own, resx files wll be compiled in assemblies per folder, while the rest of the source code (aspx, aspx.cs) will be compiled into a single (and huge, depending on number of pages) assembly, and all will be in the bin folder of the web application as dll files.

If you do not pre-compile, these resources (aspx files for instance) will be compiled with the first request targeting that page.

This will enable you to make aspx and aspx.cs deployments without recycling the application.

And because a web site canot be both pre-compiled and compiled-on-demand, VS cannot run your published web site where your source code is located. But if you don't pre-compile, your source code can directly be served (since the first request will compile the resources and the compiled assemblies will go under C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files (or another explicitly set temp path for shadow assemblies)

Upvotes: 1

Related Questions