Last post Feb 19, 2009 10:59 AM by hongping
Feb 18, 2009 10:03 AM|furryyuri|LINK
I am getting this error when I try to build my WDP. "Error 7 The precompilation target directory ....cannot be in the same tree as the source application directory"
It seems to me that the error is because I have tried to attach my WDP to a project that also happens to live at the root of the directory. I have a solution with a dozen projects, and one of those happens to be the root of the entire website.
So, can I not add a WDP to this root project? I am only adding WDP in order to replace web.config sections at the publish step, and this root project of course, holds all the main configuration settings.
Feb 18, 2009 11:01 AM|hongping|LINK
By default, WDP uses a output directory that is underneath the project, such as C:\MyWebsite\MyWDP\bin\Debug
You need to change the output directory to another folder that is outside of your website, such as C:\MyWebsite_Output.
Feb 18, 2009 11:09 AM|furryyuri|LINK
2 followup questions:
1. I'm using WAP, not website - does that matter?
2. I'm getting the "It is an error to use a section registered as" blah blah when I create the WDP outside of my WAP, and try to build it. I guess the directory in which I place the WDP needs to be configured as an app via IIS?
Feb 18, 2009 11:19 AM|furryyuri|LINK
OK, I'm actually getting this ""It is an error to use a section registered as" error when I try to build the WDP, if I try to place it anywhere outside of my solution directory (which is in inetpub). I tried placing it in inetpub outside of my solution folder,
I tried placing it in the Visual Studio Projects folder outside of inetpub - either way I get that error on build. Note that I am building right after I create the WDP, so I haven't actually added anything to the project yet or configured it in any way.
Feb 18, 2009 11:22 AM|hongping|LINK
What is the location of your WAP?
What is the location of your WDP?
What is the location of the output of your WDP?
Feb 18, 2009 03:46 PM|furryyuri|LINK
My WAP is in wwwroot. I originally had the WDP inside that project (physically) because the project I need to set up the deployment for is the root directory.
Per your advice I tried setting the location of the WDP to be outside the directory of the WAP, but also inside wwwroot, in its own folder.
In either case I get the error I mentioned.
Feb 18, 2009 04:36 PM|hongping|LINK
You should NOT put your WAP under wwwroot. You also need the WDP project itself to be in a separate location, outside of the WAP location. This is because WDP uses a tempDir and that needs to be outside the web site location.
After you build the WDP, you can proceed to copy the output to the wwwroot.
Feb 18, 2009 05:27 PM|furryyuri|LINK
why not? I have never heard that before. All of my websites are in wwwroot, so I can run them via localhost.
Feb 18, 2009 08:45 PM|hongping|LINK
In your case, you are trying to put the WDP under WAP. As mentioned, this cannot be done because when the WDP builds, it will create a tempDir under its project folder, thus you will get the error that the target (tempDir in this case) cannot be under the
You can go with wwwroot if you want, but the WDP cannot be under the WAP. I was just suggesting that the final output be under wwwroot, so that you can build your WAP and WDP separately.
Feb 18, 2009 08:56 PM|furryyuri|LINK
I see what you are saying. The trouble is my WAP is at the root level of the website - everything is 'under' it, other projects, images folder, etc. I tried, when creating the WDP, to specify a location outside of the WAP folder, and I get that "It is an
error to use a section registered as" etc error, and I don't know why. I will try again. I don't know what else to do. I appreciate your advice!
Feb 18, 2009 09:10 PM|furryyuri|LINK
OK, I tried again. I put the WAP on my desktop, and the WDP I pointed to My Documents/ VS2005/ Projects. I went to build the WDP and got "Error 30 It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application
level. This error can be caused by a virtual directory not being configured as an application in IIS."
The error is actually pointing to, not the root project that I associated the WDP with, but another one - the first one listed alphabetically in the solution. However if I remove the WDP from the solution, the whole thing builds.
Does something need to be a virtual directory in order to use WDP? I didn't think so, because if I associate the WDP with another project in the solution other than the root one, it builds fine.
Feb 18, 2009 09:40 PM|hongping|LINK
You might be using some web.config that can only be set at root level. Try creating a new WAP instead to see if you can build the WDP successfully.
Feb 19, 2009 06:38 AM|furryyuri|LINK
I will try that! Out of curiosity, what kind of web.config can only be set at root level?
Feb 19, 2009 09:45 AM|furryyuri|LINK
OK I made a new test solution with 2 projects. I put one physically as a subdir of the other. I then attached a WDP to the subdir WAP. It built fine. However I then tried out the enabling of web.config section replacement. Although the solution builds, the
web.config section is not replaced and the default page, which I set to run some code after connecting to the DB, gives an error that it cannot find the connectionstring in the config.
Also, I went back to the original solution I was working with. I removed the entire web.config from the project that threw the error when I built the WDP, because that project didn't need it, I just left it when I made the project initially. And now I get
an error that it cannot find 2 user controls in another project. You see, I am sharing the user controls from one project across the solution, by using a pre-build event to copy these controls. I don't know if there is some conflict betwen this pre-build event
and the WDP.
Feb 19, 2009 10:59 AM|hongping|LINK
I meant certain web.config *sections*, not the entire web.config file. For example, you will get the error "It is an error to use section registered as ... " if you try to use a section that is MachineToWebRoot in a virtual application not at the wwwroot,
or a section that is MachineToApplication in a subdirectory of an application.
It seems your project set up is quite complicated. Building WDP involves a few steps by default, such as running aspnet_compiler and aspnet_merge (even this depends on what your "Compilation" and "Output Assemblies" settings are in the WDP), and you also
have some additional steps to copy controls and replace sections in the web.config.
The main issue here is that WDP might need to create a temporary directory, and once it does that, the tempDir is no longer considered at the "WebRoot" level, so some settings that existed in the wwwroot's web.config will trigger the error you are seeing.
What settings do you have in the "Compilation" and "Output Assemblies" properties of the WDP? Also, could you copy and paste the text from the output window (From menu, choose Debug -> Windows -> Output. Then choose from the dropdown box: Show output from
"Build") ? That will give you more information as to what WDP is doing under the covers.